Are JavaScript arrays actually linked lists?

前端 未结 6 740
眼角桃花
眼角桃花 2020-12-15 04:47

I\'m new to Javascript, and notice that you don\'t need to specify an array\'s size and often see people dynamically creating arrays one element at time. This would be a hug

6条回答
  •  北海茫月
    2020-12-15 05:27

    They are actually more like custom objects that use the properties as indexes. Example:

    var a = { "1": 1, "2": 2};
    a.length = 2;
    for(var i=0;i

    a will behave almost like an array, and you can also call functions from the Array.prototype on it.

提交回复
热议问题