What's the difference between objects and associated array in javascript?

后端 未结 5 545
醉梦人生
醉梦人生 2020-12-11 16:30

The Confusing discussion

In this question, there is a discussion on the concepts of associated array and object in javaScript which I got a bit confused.

In

5条回答
  •  [愿得一人]
    2020-12-11 17:27

    Associative Array

    In computer science, an associative array (also called a map or a dictionary) is an abstract data type composed of a collection of (key,value) pairs, such that each possible key appears at most once in the collection.

    As far as I know objects in JavaScript match that definition.

    Of course there is no unique "Associative Array" object, that's any different then any other normal object. So if you want associative array functionality use a javascript object.

    However the following is a common piece of misinformation

    There is no associative array in JavaScript

    You should simply ignore these people, maybe try to convince them they are wrong.

提交回复
热议问题