Push: adding a return value to the end of the array is the new length of the array
Unshift: adding a return value to the beginning of the array is the new length of the array
Pop: Delete the end item of an array the return value is a deleted array item
Shift: Delete Array Start item returns the beginning item that was deleted
Splice: deleting any item in an array returns a value that is a deleted array item
Slice: Copy array return value is copied to the new array after the value is written does not contain the last item being copied
Stitching:
Concat: stitching an array together with another array to return a well-stitched array
Join: stitch Each item in the array into a string by the specified delimiter
Sort:
Reverse: Reverse Array return value reverse array original array change
Sort: Bubble sort based on anonymous function b-a reverse a-b ascending
Poor compatibility:
IndexOf: returns the index of the get item in the array
LastIndexOf: returns the last index that gets the item that appears in the array
ForEach: looping through an array parameter is an anonymous function returned by default to undefined
Map: looping through an array parameter is an anonymous function
Not much, just a previous code.
varary = [1,2,3,4,5,6,7,8,9,0]; varary1=[1,5,7,4]; varary2=[2,3,4,5,7,3,4,5]; varA=ary.splice (2,3,5);//deleting any of the items in an array can be extended to push,unshift,pop,shift,slice most commonly used varB=ary.splice (2,1); /*var a= "test"; var b=[123]; For use with the foreach test*/ varC=ary.push (1);//add an item at the end of the array varD=ary.unshift (3);//add an item at the beginning of the array varE=ary.pop ();//deletes an item at the end of an array varF=ary.shift ();//deletes an item at the beginning of the array varG=ary.slice (2,5);//Copying an array varH=ary.concat (ary1,ary2). concat (1,2,2,2,2,[456654]);//an array of assignments if there are no parameters or if the argument is () null varI=ary.join (' + ');//stitching each item in the array into a new string with the specified delimiter varJ=ary.reverse ();//Reverse Sort original array Change varK=ary1.sort (function(a, B) {returnb-a;}); varL=ary2.indexof (4);//returns the index of the get item that appears in the array varM=ary2.lastindexof (4);//returns the last index in the array where the Get item appears varN=ary2.indexof (9);//returns 1 if the Get item does not exist varO=ary.foreach (function(a, b) {console.log (a, b)}); varP=ary2.map (function(){}); Console.log (a); Console.log (b); Console.log (c); Console.log (d); Console.log (e); Console.log (f); Console.log (g); Console.log (h); Console.log (i); Console.log (j); Console.log (k); Console.log (l); Console.log (m); Console.log (n);//Console.log (a,xb);Console.log (o); Console.log (ary); Console.log (ary1);
Splice's expanded Use:
Analog Push Ary.splice (ary.length,0,x)
Analog pop Ary.splice (ary.length-1,1)
Analog Unshift Ary.splice (0,0,x)
Analog Shift Ary.splice (0,1)
Splice (0) from 0 to the end ==> all deleted operations ==> return all array items ==> cloned array
Common methods and return values for arrays