属性要为索引(数字)属性,必须有length属性,最好加上push
var obj = {
"0" : 0,
"1" : 1,
"length":2,
"push":Array.prototype.push,
"splice":Array.prototype.splice
}
obj.push("c");
obj.push("d")
Array.prototype.push = function(target){
obj[obj.length] = target;
obj.length ++;
}
网友评论