Skip to content

Instantly share code, notes, and snippets.

@jafow
Created April 24, 2016 20:40
Show Gist options
  • Save jafow/55e191ce4399daea6177bcf8fff4ba3e to your computer and use it in GitHub Desktop.
Save jafow/55e191ce4399daea6177bcf8fff4ba3e to your computer and use it in GitHub Desktop.
Example implementations of delay
function delay (fn, wait) {
var args = Array.prototype.slice.call(arguments, 2)
setTimeout(function () {
return fn.apply(this, args)
}, wait)
}
// with ES6 rest operator instead of slicing arguments object
const delay2 = (fn, wait, ...args) => {
setTimeout(() => fn.apply(this, args), wait)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment