Skip to content

Instantly share code, notes, and snippets.

@gavinblair
Last active August 29, 2015 14:04
Show Gist options
  • Save gavinblair/5ab2a9e85ab3d740d2ba to your computer and use it in GitHub Desktop.
Save gavinblair/5ab2a9e85ab3d740d2ba to your computer and use it in GitHub Desktop.
Pass arguments to setTimeout
setTimeout(
(function(el){
return function(){
el.hide();
};
}($(this))), 2000);
@dmamills
Copy link

Something like this also works:

var obj = { thing:true };
setTimeout((function() {
  console.log(this.thing)
}).bind(obj),2000);

@gavinblair
Copy link
Author

cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment