JavaScript Array Object
1. Array creation:
(1) using the array constructor
(2) array literal notation
2. Array Method:
Here are a few important array prototyping methods:
1) Join ()
Join (Separator): Sets the element group of the array as a string, separator as a delimiter, or by default with a comma delimiter, which receives only one argument: the delimiter.
2) push () and pop ()
Push (): can accept any number of arguments, add them to the end of the array one by one, and return the length of the modified array.
Pop (): Removes the last item at the end of the array, reduces the length value of the array, and then returns the item that was removed. 4
3) Shift () and unshift ()
Shift (): Deletes the first item of the original array and returns the deleted element, or returns undefined if the array is empty.
Unshift (): Adds a parameter to the beginning of the original array, returning the length of the array.
4) sort ()
Sort (): Arranges array items in ascending order-minimum at the front, maximum at the last face.
When sorting, the sort () method invokes the ToString () transformation method for each array item, and then compares the resulting string to determine how to sort.
5) Reverse ()
Reverse (): Reverses the order of the array items.
6) concat ()
Concat (): Adds a parameter to the original array, which creates a copy of the current array, adds the received parameter to the end of the copy, and finally returns the newly constructed array. Without passing arguments to the concat () method, it simply copies the current array and returns a copy.
7) Slice ()
Slice (): Returns a new array that consists of the entries from the original array that specify the starting subscript to the end subscript. The slice () method can accept one or two parameters, that is, to return the starting and ending positions of an item. In the case of only one argument, the slice () method returns all items starting at the specified position of the parameter to the end of the current array. If there are two parameters, the method returns the item between the start and end positions--but not the end position.
8) IndexOf () and LastIndexOf ()
IndexOf (): Receives two parameters: the subparagraphs (optional) to find indicates the index at which to find the starting point. Where you start looking backwards from the beginning of the array (position 0).
LastIndexOf: Receives two parameters: the subparagraphs (optional) to find indicates the index at which to find the starting point. Where you start looking forward from the end of the array.
Both of these methods return the position of the item you are looking for in the array, or return it if it is not found. 1. The congruent operator is used when comparing the first argument to each item in the array.
Not finished, to be continued ....
2-javascript Array Object (array)