Let's take a look at its definition:
The code is as follows:
var arrayobj = new Array ()
var arrayobj = new Array ([size])
var arrayobj = new Array ([element0[, element1[, [, ELEMENTN]]])
Where: Arrayobj is the variable name assigned to the array object.
Size because the subscript of an array is zero-based, the subscript of the created element will be from zero to size-1.
Element0,..., ELEMENTN This creates an array of n + 1 with an element of n + 1. You must have more than one element when you use this syntax.
If you pass only one parameter to the array's constructor, and the argument is a number, it must be an unsigned 32-bit integer (approximately 4 billion). The value becomes the size of the array. A run-time error occurs if the value is numeric, but is less than 0 or is not an integer.
If a single value is passed to the array constructor and is not a number, the Length property is set to 1, and the unique element value becomes a single passed-in parameter.
Because the JS array is an analytic array, that is, although you can assign multiple elements to an array, only the elements that contain the data exist. This reduces the amount of memory used by the array.
The array object has three built-in properties: Constructor,length,prototype I will write a special article on constructor, Prototype,arguments and other object properties, here is not to say more. Here we look at some of the methods built into the array, which is important to us because it is often used.
Concat method: Joins two or more arrays and returns a new array. It is worth noting that (reference type) for object parameters copied from the array being connected to the new array. Copying still points to the same object, regardless of which of the new array and source array changes, will cause another change; (value type) copy only its value for a numeric value or string that is attached to the new array. A change in the value of an array does not affect the value in the other array. Example: