Array Object Methods
1.arr.concat()
Connecting two or more arrays, and returns the result.
- Value of the connection array
- Connecting two arrays
- Connecting three arrays
2.arr.join()
All the elements of the array into a string. Elements separated by the specified delimiter. And returns a string
The method of transfer is generally used as a string array. (The following is often used)
// arr variable STR
arr.join ()
// STR becomes ARR
str.split ( ',')
3.arr.push()
To the array at the end of addition of one or more element, and returns the new length. Remember that push () directly modify the arrayObject, instead of creating a new array
4.arr.unshift()
To an array of the beginning of the addition of one or more elements, and returns the new length .
5.arr.pop()
Used to remove and return the last element of the array.
6.arr.shift()
For the first element of the array from which to delete , and returns the value of the first element.
7.arr.slice(start, end)
To return to the selected elements from the existing array. Note: -1 is the last element. . .
8.arr.splice()
Delete elements, add a new element to the array . Remember that returns a new array to remove that element formed
// This method is very powerful and can remove elements anywhere on the
// at the same time can also add an element to take any position
9.arr.sort(fn)
- According to figures ordering size (small to large)
- According to the English alphabetical order (a to z)
- According to fn
10.arr.reverse()
Reverse the order of elements in the array. This method will change the original array, without creating a new array. Returns the new results
11.arr.toString()
The array may be converted to a string, and returns the result
Happy Mid-Autumn holiday!