IE6-8 实现 Function protoypte bind问题

myseemydog 2013-11-07 04:09:29
   
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();

这里问什么要把这个返回出来的函数原型指向先前对象里面getAge的原型呢?


有大大说是EMCA262标准、、还有人说是断开引用。
求解
...全文
103 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
myseemydog 2013-11-07
  • 打赏
  • 举报
回复
。。Any 大神?

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧