1, what is an array?
An array is a collection of data.
Its manifestation is a continuous memory address in memory.
The array name is actually the first address of consecutive memory addresses.
2. About the array features in js.
You don't need to specify a data type when defining an array.
You can define an array without specifying its length.
Arrays can store data of any data type (for example, one element holds integers and one element holds strings, which is ok in JS).
Syntax for creating arrays:
var arr =;
Differences between Json arrays:
The subscripts of 1 and Json are a string, such as Json.a when calling the first data. The subscript of an array is a number, such as arr[0]
2.Json has no length, and arrays have length.
Use Json to store data, and use for (element variable in variable name) if you need to loop. Because Json has no length, for is used in the loop, which can be used for Json and arrays.
For (I in JSON) {
sentence
};
When to use the for loop and when to use the for in loop?
Array: loop for (I = 0, I
JSON: loop for (II in JSON) with for in {};
10. Attention
Arrays have only one array length attribute.
If you don't assign a value to the array, you will get undefined, and the print is ""
The length of the array is not extended automatically enough, so there is no problem of crossing the line.
The above is what I arranged for you, and I hope it will help you in the future.
Related articles:
A detailed description of the use of key-value pairs stored in js
NodeJS parent process and child process resources * * * enjoy detailed steps.
Concept and usage of JS anonymous self-executing function