1. Create an Array object
Syntax for creating an Array object
Var Array name = new Array ();
After defining the array, you need to add elements to the array. The format is as follows:
Array name [ <Subscript> ] = Value;
2. Array Object Attributes
The Array object only provides four attributes.
Index: Specifies the position where the character matches the string, or if-1 is not found.
Input: Specifies the original string that matches the regular expression.
Length: returns the length of the array, that is, the number of elements in the array. This attribute can be used to easily traverse the array.
Prototype: add the newly defined attribute or method to the Array object. Then, the instance of this object can call this attribute or method.
3. Array object Method
Concat (): For object link reference, copy the value of a character or string
Join (): all elements separated by the specified separator
Pop (): removes the last element from the array and returns the element. If the array is empty, underfined is returned.
Push (): append new elements in the order they appear.
Shift (): remove the first element from the array and return it.
Unshift (): inserts these elements into the beginning of an array so that they are sorted in order in the parameter table.
Reverse (): sorts array elements in the opposite direction.
Sort (): returns the sorted Array object. By default, elements are sorted in ascending order of ASCII characters.
Splice (): removes the specified number of elements starting from the start position and inserts new elements to modify the array. The returned value is a new Array object consisting of the removed elements.
TolocalString (): returns a value in the form of a string value, which is suitable for the region settings in the current environment
ToString (): returns the string representing the object.
ValueOf (): returns the original value of the specified object.