587 B
587 B
title, tags, expertise, cover, firstSeen, lastUpdated
| title | tags | expertise | cover | firstSeen | lastUpdated |
|---|---|---|---|---|---|
| Delay function execution | function | intermediate | blog_images/interior-13.jpg | 2018-01-24T14:32:20+02:00 | 2020-10-19T18:51:03+03:00 |
Invokes the provided function after ms milliseconds.
- Use
setTimeout()to delay execution offn. - Use the spread (
...) operator to supply the function with an arbitrary number of arguments.
const delay = (fn, ms, ...args) => setTimeout(fn, ms, ...args);
delay(
function(text) {
console.log(text);
},
1000,
'later'
); // Logs 'later' after one second.