Skip to content

Files

Latest commit

 

History

History
20 lines (16 loc) · 409 Bytes

delay.md

File metadata and controls

20 lines (16 loc) · 409 Bytes

delay

Invokes the provided function after wait milliseconds.

Use setTimeout() to delay execution of fn. Use the spread (...) operator to supply the function with an arbitrary number of arguments.

const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);
delay(
  function(text) {
    console.log(text);
  },
  1000,
  'later'
); // Logs 'later' after one second.