Skip to content

Instantly share code, notes, and snippets.

@jmarmolejos
Created January 14, 2016 11:03
Show Gist options
  • Select an option

  • Save jmarmolejos/32b854cfebf076c102d0 to your computer and use it in GitHub Desktop.

Select an option

Save jmarmolejos/32b854cfebf076c102d0 to your computer and use it in GitHub Desktop.
class Foo {
constructor() {
this.baz = "baz";
this.doStuff = this.doStuff.bind(this);
}
doStuff() {
console.log(this.baz);
}
}
let foo = new Foo();
setTimeout(foo.doStuff, 500); // Logs "baz", hooray!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment