Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node wait 10 seconds

async function init() {
  console.log(1);
  await sleep(1000);
  console.log(2);
}

function sleep(ms) {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
}

// one liner
let sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to remove cors error from node app 
Javascript :: space between react native 
Javascript :: remove all node_modules folders recursively 
Javascript :: email validation using javascript 
Javascript :: first child element javascript 
Javascript :: jquery is numeric 
Javascript :: puppeteer get value of div 
Javascript :: how to remove the last character of a string in javascript 
Javascript :: js get first object value 
Javascript :: Could not resolve dependency error peer react@"^16.8.0 || ^17.0.0" from @material-ui/core@4.12.4 
Javascript :: nangular make window available 
Javascript :: javascript add event listener to all input 
Javascript :: css how to make a div scrollable 
Javascript :: js range 1 to n 
Javascript :: jqiery call onclick in another element 
Javascript :: javascript get all elements with class 
Javascript :: roman numeral converter + javascript 
Javascript :: jquery set select readonly 
Javascript :: javascript seconds to min and seconds 
Javascript :: javascript replace all characters except letters and numbers 
Javascript :: react background image 
Javascript :: get localstorage 
Javascript :: step over vs step into vs step out 
Javascript :: Manifest 3 content security policy 
Javascript :: get lines as list from file node js 
Javascript :: Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. 
Javascript :: converting binary to text js 
Javascript :: Delete icon Mui 
Javascript :: jquery add remove class clicked element 
Javascript :: image touchable opacity react native 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =