What’s the difference between “{}” and “[]” while declaring a JavaScript array?

前端 未结 7 2149
半阙折子戏
半阙折子戏 2020-12-02 10:04

What’s the difference between “{}” and “[]” while declaring a JavaScript array? Normally I declare like

var a=[];

What is the meaning of de

7条回答
  •  天涯浪人
    2020-12-02 10:15

    they are two different things..

    [] is declaring an Array:
    given, a list of elements held by numeric index.

    {} is declaring a new object:
    given, an object with fields with Names and type+value,
    some like to think of it as "Associative Array". but are not arrays, in their representation.

    You can read more @ This Article

提交回复
热议问题