var obj = {
length: 0,
splice: function() {}
};
//console.log(obj) => []而不是{}
//jQuery里面就用这个模拟数组行为的
//类似这样:
var arr = [],
splice = arr.splice,
push = arr.push,
obj = {
length: 0,
splice: splice,
push: push
};
//obj.push(1) => [1]
这个是什么原理?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
第一个还是对象不是Array console.log(obj instanceof Array) ==false