js built-in objects -Array

Array object
  1, the array conversion
    Array.join () action: the value of a string array splice, will return the string
    Array.join () parameter does not pass, according to the default comma (,) splicing
    array.join ( "-") by - splicing
    array.join ( "") without any segmentation empty string, immediately
  2, the operation of the array deletions
    Array.push () additive element from the rearmost arrays - can add one or more - Returns a new array of length
    array.pop () removes an element from the final surface of the array - remove one - returns that element deleted
    Array.unshift () to add elements of the array from the front - Returns the new array length - can add one or more
    array.shift () removes an element from the top of the array --- remove one - returns that element deleted
pop () and shift () does not accept the mass participation, delete only one element of the role, even pass parameters also no use
3, flip, and sort arrays
arr.reverse () - Flip Array
arr.sort () --- array is sorted in alphabetical order by default ordering
arr.sort (function (a, b)) before the latter represents a return ab b represents an ascending descending return ba
4, and an array of splicing taken
arr.concat () - Array merger will not affect the original array
arr.slice () - array taken, taken out of a portion from the array, and returns a new array (does not change the original array)
1, arr.slice () - taken from beginning to end
2, arr.slice (begin) - taken from the start to the end begin
3, arr.slice (begin, end) - taken from begin to end, including begin, not including the end

arr.splice () - Delete or add an array of array elements, remove any of the replacement at any position of the array
arr.splice (x, y) --x indicates where to start puncturing y represents the number of deleted
arr.splice (x, y, z) --x indicates where to start puncturing y represents a number of puncturing z represents alternative content

5, find an array of elements in the array to find the location of the first occurrence
arr.indexOf () array used to find the first occurrence of an element subscript
---- If the value does not exist in the array, return -1
arr.lastIndexOf () to find the value in the array the last occurrence of the subscript
---- If the value does not exist in the array, return -1

Guess you like

Origin www.cnblogs.com/hhmmpp/p/11070267.html