这是js权威指南上的一个例子,我运行的时候报了Illegalinvocation错误。。我是我不知道为什这样写会报错,求告知。谢谢。代码如下:functionRange(from,to){this.from=from;this.to=to;}Range.prototype={includes:function(x){returnthis.from
2 回答

ITMISS
TA贡献1871条经验 获得超8个赞
r.foreach(console.log);//改成r.foreach(console.log.bind(console));原因在于console.log这个函数实现需要console作为函数的this
添加回答
举报
0/150
提交
取消