87,997
社区成员




Function.prototype.bind = function (oThis) {
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
fBound = function () {
return fToBind.apply(this instanceof fNOP && oThis
? this
: oThis || window,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
var person = {
age:10,
getAge:function(){
return this.age;
}
}
//
var boundGetAge = person.getAge.bind(person);
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();