👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.

settimeout javascript

The standard way to create a delay in JavaScript is to use the setTimeout(callback, ms) method. The first parameter is the callback function, the second one is the duration in milliseconds:

setTimeout(myFunction, 2000);

function myFunction() {
	console.log("End of delay!");
This can also be used with anonymous function:

setTimeout( () => { console.log("End of delay!"); }, 2000);