Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript sleep function

sleep = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));

//        V  Must add this async keyword
sayHi = async () => {
  	// V Must include await
	await sleep(1000); // Sleep 1000 milliseconds (1 second)
  	console.log('Hi');
  	// Rest of code...
}
Comment

javascript function to sleep

setTimeout(function (){
  
  // Something you want delayed.
            
}, 5000); // How long you want the delay to be, measured in milliseconds.
Comment

JavaScript Sleep Function

await sleep(<duration>);
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to change html element in javascript 
Javascript :: using underscore javascript number 
Javascript :: save jshint 
Javascript :: gitignore subfolders 
Javascript :: store with redux-thunk 
Javascript :: jquery cdn by google 
Javascript :: toggle boolean state react 
Javascript :: sveltekit tailwind 
Javascript :: find items from array of ids mongoose 
Javascript :: copy element jquery 
Javascript :: get index in map javascript 
Javascript :: capitalize mdn 
Javascript :: object has property 
Javascript :: javascript copy value to clipboard 
Javascript :: js find duplicates in array 
Javascript :: jquery date 
Javascript :: convert json into map in java example 
Javascript :: element remove class 
Javascript :: http module in nodejs 
Javascript :: xlsx to json using xlsx react 
Javascript :: react route path exact 
Javascript :: lodash compare array without order 
Javascript :: ** javascript Exponentiation 
Javascript :: random color 
Javascript :: how to use a regex expression in kibana query 
Javascript :: remove spaces from string javascript 
Javascript :: Check if an array contains a object in javascript 
Javascript :: convert namednodemap to object 
Javascript :: type checking js vscode 
Javascript :: post request with authorization 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =