The Array of JavaScript is also an interesting topic. Although it is named Array, the method on the Array object is more like the result of mixing many things together. In traditional programming languages such as C/Java, elements in the array need to have the same data type, but as weak JavaScript, there is no such restriction, the Array of JavaScript is also an interesting topic. Although it is named Array, the method on the Array object is more like the result of mixing many things together. In traditional programming languages such as C/Java, elements in the array need to have the same data type, but as weak JavaScript, there is no such restriction. In fact, javaScript can have different types of elements in the same array.
Method |
Description |
Concat () |
Concatenate two or more arrays and return results. |
Join () |
Put all elements of the array into a string. The elements are separated by the specified delimiter. |
Pop () |
Delete and return the last element of the array. |
Push () |
Add one or more elements to the end of the array and return a new length. |
Reverse () |
The order of elements in the array is reversed. |
Shift () |
Delete and return the first element of the array. |
Slice () |
Returns the selected element from an existing array. |
Sort () |
Sorts the elements of an array. |
Splice () |
Delete elements and add new elements to the array. |
Unshift () |
Add one or more elements to the beginning of the array and return a new length. |
ValueOf () |
Returns the original value of the array object. |
It can be seen that the array objects of JavaScript are complex, including pop, push, and other operations similar to stack, as well as slice, reverse, and sort operations similar to list operations. Perhaps because of this, the Array Function in JavaScript is very powerful.