Javascript: var map = {}; var list = [];

Can someone tell me what exactly the two above javascript lines do? And more importantly, what did he name, so I can find some javascript links to find out about this? I assume that they create some form of array into which objects can be added ...?

+4
source share
2 answers

It creates an empty dictionary in map and an empty array in list .

Read these structures at http://www.geocities.com/schools_ring/ArrayAndHash.html .

+2
source

Curly braces - syntax for creating a Javascript object (which is really an illustrious collection of key / value pairs); brackets create a volatile array.

They are called literals, and they are convenient shortcuts to help you create objects and arrays without a lot of typing (good, because you use them all the time). Many other programming languages ​​have the same literal syntax for maps and arrays.

+8
source

All Articles