标签:
Function.prototype.bind =
function
(scope) {
var
fn =
this
;
return
function
() {
return
fn.apply(scope);
};
}
var
foo = {
x:
3
}
var
bar =
function
(){
console.log(
this
.x);
}
bar();
// undefined
var
boundFunc = bar.bind(foo);
boundFunc();
// 3
标签:
原文地址:http://my.oschina.net/u/1992917/blog/413199