Are JavaScript arrays actually linked lists?

前端 未结 6 747
眼角桃花
眼角桃花 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:34

    Javascript arrays are typically implemented as hashmaps (just like Javascript objects) with one added feature: there is an attribute length, which is one higher than the highest positive integer that has been used as a key. Nothing stops you from also using strings, floating-point numbers, even negative numbers as keys. Nothing except good sense.

提交回复
热议问题