【发布时间】:2014-10-18 12:36:35
【问题描述】:
好吧,我在这里杀了我的大脑,我有一个数组
var myArray = ['Bob', 'Sue', 'Jim'];
myArray.__proto__ = new Entity();
//Entity looks something like this
Entity = function(){
this.isChanged = false;
this.add = function(newPerson){
alert(this.length); //alerts with 3
alert(JSON.stringify(this)); //alerts a {}
this.push(newPerson);
this.isChanged = true;
}
}
push 在一个对象上不存在,但它显然是一个数组,根据返回 3 的警报。
非常好奇如何访问我的数组,这要归功于我的 proto
【问题讨论】:
标签: javascript arrays