var array_like = {};array_like[0] = "test 0";array_like[1] = "test 1";array_like[2] = "test 2";array_like[3] = "test 3";//关键点array_like.length = 4;//为对象设置length属性array_like.splice = [].splice;//同时设置splice属性为一个函数console.log(array_like)
打印出来的是数组形式
Object(4) ["test 0", "test 1", "test 2", "test 3", splice: ƒ]
删除
array_like.splice = [].splice;
打印的是对象形式
{0: "test 0", 1: "test 1", 2: "test 2", 3: "test 3", length: 4}
原因:



参考文章:
如何在JavaScript中手动创建类数组对象 - 小小沧海 - 博客园www.cnblogs.com