Skip to content

Instantly share code, notes, and snippets.

@dd1994
Last active November 28, 2015 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dd1994/60943d59b2d88317e9d0 to your computer and use it in GitHub Desktop.
Save dd1994/60943d59b2d88317e9d0 to your computer and use it in GitHub Desktop.
an example of setTimeout and clearTimeout
'use strict'
let timeoutID1 = setTimeout(function(arg1, arg2) {
console.log(arg1)
console.log(arg2)
}, 2000, 'hello1', 'go1')
let timeoutID2 = setTimeout(function(arg1, arg2) {
console.log(arg1)
console.log(arg2)
}, 2000, 'hello2', 'go2')
// timeoutID is a number in broswer,but a complex object in node.js
console.log(timeoutID1, timeoutID2)
clearTimeout(timeoutID2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment