Implement Array-like behavior in JavaScript without using Array

后端 未结 10 1216
暖寄归人
暖寄归人 2020-12-13 07:45

Is there any way to create an array-like object in JavaScript, without using the built-in array? I\'m specifically concerned with behavior like this:

var sup         


        
10条回答
  •  孤城傲影
    2020-12-13 08:07

    Sure, you can replicate almost any data structure in JavaScript, all the basic building blocks are there. What you'll end up will be slower and less intuitive however.

    But why not just use push/pop ?

提交回复
热议问题