类数组属性要为(数字索引),必须有length属性,最好加上push
//类数组 var obj = { "0": 'a', "1": 'b', "2": 'c', 'length': '3', 'push': Array.prototype.push, 'splice': Array.prototype.splice }
类数组的实现
//类数组的实现 Array.prototype.push = function (target) { obj[obj.length] = target; obj.length++; }
例
var obj = { '2':'a', '3':'b', 'length':2, 'push':Array.prototype.push } obj.push('c'); obj.push('d');//2:c,3:d