类数组对象
类数组对象没有多大用处,完全可以使用数组类型替代。
自定义类数组对象
const a = {
0: 'a',
1: 'b',
2: 'c',
3: 'd',
name:'chen',
age: 23,
length: 4,//注意length属性值
'push': Array.prototype.push, //添加一个push方法
'splice': Array.prototype.splice
}
a.push('e');
Array.prototype.unshift.call(a, 'f'); //可以使用回调数组方法
console.log(a);