Skip to content

Instantly share code, notes, and snippets.

@ghostbar
Created January 4, 2016 22:47
Show Gist options
  • Save ghostbar/81cb47ac4a03a6140a40 to your computer and use it in GitHub Desktop.
Save ghostbar/81cb47ac4a03a6140a40 to your computer and use it in GitHub Desktop.
var timeoutIds = []
function newTimeout (fn, time) {
return setTimeout(fn, time)
}
function toBeSent () {
console.log('I\'m being called! Timeout!', Date.now())
console.log(timeoutIds)
}
function theCall () {
for (var i=0; i < 2; ++i) {
var rand = Math.floor(Math.random() * (3000 - 200)) + 200
timeoutIds.push(newTimeout(toBeSent, rand))
}
}
theCall()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment