Skip to content

Instantly share code, notes, and snippets.

@eshacker
Created February 1, 2016 08:43
Show Gist options
  • Save eshacker/0353b1f87902b82b86b3 to your computer and use it in GitHub Desktop.
Save eshacker/0353b1f87902b82b86b3 to your computer and use it in GitHub Desktop.
A short tutorial on bind
var x = 1;
var A = {
x : 10,
get: function(){ return this.x; }
};
var a = A.get;
console.log(a()); // 1
var b = A.get.bind(A); // 10
console.log(b());
var c = a.bind(A);
console.log(c()); // 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment