How to use the setTimeout function in 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);
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);
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);
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);
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 13351 | alphons | https://en.ans.wiki/20/how-to-use-the-settimeout-function-in-javascript | 1 |
| 1 | 12149 | en | https://en.ans.wiki/20/how-to-use-the-settimeout-function-in-javascript | 11 |