👋 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:
This can also be used with anonymous function:setTimeout(myFunction, 2000);
function myFunction() {
console.log("End of delay!");
}
setTimeout( () => { console.log("End of delay!"); }, 2000);