Created
February 1, 2016 08:43
-
-
Save eshacker/0353b1f87902b82b86b3 to your computer and use it in GitHub Desktop.
A short tutorial on bind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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