This article analyzes the usage of Javascript arrays and dictionaries with examples. Share it with everyone for your reference. The specific analysis is as follows:
Javascript’s array Array is both an array and a dictionary.
Let’s take an example to see how to use arrays.
Then traverse the array. Note that the result of i is 0 and 1, and the result of a[i] is a string.
This is very similar to traversing the properties of objects mentioned in the previous article.
Let’s take a look at how to use the dictionary.
Dell: 600
Next, let’s take a look at the interesting part of Javascript, still the above example.
We can think of computer_price as a dictionary object, and each key value is an attribute.
That is to say, Acer is an attribute of computer_price. We can use it like this: computer_price.Acer
Let’s take a look at the simplified declaration methods of dictionaries and arrays.
I hope this article will be helpful to everyone’s JavaScript programming design.