Created
March 20, 2018 05:44
-
-
Save a1exlism/697ca27efe6b093cb11952d79f73b1d4 to your computer and use it in GitHub Desktop.
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
function f(){ | |
return this.a; | |
} | |
var a = {a: 'foo'}; | |
var b = {a: 'bar'}; | |
var x = f.bind(a); | |
var y = x.bind(b); | |
// bind 只能绑定一次, 可重复绑定 | |
console.log(x()); | |
console.log(y()); | |
console.log(f.bind(b)()); | |
// foo | |
// foo | |
// bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment