javascript——类数组

Posted Sunshine

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript——类数组相关的知识,希望对你有一定的参考价值。

var obj = {
  "2": "a",
  "3": "b",
  "length": 2,
  "push": Array.prototype.push
}
//属性要为索引(数字)属性,必须有length属性,最好加上push

//push 相当于这样
// Array.prototype.push = function (target){
//   obj[obj.length] = target;
//   obj.length ++;
// }

以上是关于javascript——类数组的主要内容,如果未能解决你的问题,请参考以下文章