对象和控制台日志的奇怪行为此代码:foo = [{id: 1},{id: 2},{id: 3},{id: 4}, {id: 5}, ];console.log('foo1', foo, foo.length);foo.splice(2, 1);console.log('foo2', foo, foo.length);在Chrome中生成以下输出:foo1
[Object, Object, Object, Object, Object] 5
0: Object
1: Object
2: Object
3: Object
length: 4
__proto__: Array[0]
5 (index):23foo2
[Object, Object, Object, Object] 4
0: Object
1: Object
2: Object
3: Object
length: 4
__proto__: Array[0]小提琴:http://jsfiddle.net/2kpnV/那是为什么?
添加回答
举报
0/150
提交
取消