1. Stack method
Features: LIFO
Push (): Receives any number of parameters to add them to the end of the array, returning the value to the length of the modified array.
Pop (): Removes the last item from the end of the array, reduces the length value of the array, and returns the item that is removed.
2. Queue method
Features: Advanced First Out
Push (): Receives any number of parameters to add them to the end of the array, returning the value to the length of the modified array.
Shift (): Removes the first item in the array and returns the item, reducing the length value of the arrays.
Unshift (): Adds any item to the front of the array and returns the array length.
3. Reorder Methods
Reverse (): Reverses the order of the array, the returned value is a sorted array, and the original array is changed.
Sort (): The array is sorted, the return value is a sorted array, and the original array is changed.
4. How to Operate
Concat (): Creates a copy of an array, adds parameters to the end of the copy, does not change the original array, and the return value is a new array after the change.
Slice (): Receives 2 parameters, represents the starting and ending positions of the array, does not affect the original array, the return value is an array of values between the starting item and the ending item, but does not include the end item, and if the end item is not set, all values from the beginning of the starting item are returned.
Splice (): Splice (starting position, number of items to be deleted, inserted item) changes the original array, returns the deleted item, and returns an empty array without deleting the item.
5. Location method
IndexOf (the item to find, the starting index of the location to find): The return value is the index of the item location to find.
LastIndexOf (the entry to find, the starting index of the location to find): The return value is the index of the item location to find.
6. Iterative Methods
Every (): Runs the given function for each item of an array, and returns TRUE if each item returns TRUE.
Filter (): Each item of an array runs the given function, and returns a list of items that are true of the function.
ForEach (): Runs the given function for each item of the array, and the method does not return a value.
Map (): Each item of an array runs the given function, and returns a list of the results of each function call.
Some (): Runs the given function for each item in the array, and returns True if the function returns true for either item.
None of the above methods will modify the original array.
method receives three values, item (array item), index (index of item), array (Array object)
7. Merge method
Reduce ():
Reduceright ():
Two methods will iterate over all the items of an algebraic group and return a final value. Each of the two methods receives 4 parameters. Prev (previous value), cur (current value), index (index of the item), array (array object).
Any value returned by the function of the method will be automatically passed to the next item as the first argument.
JS Advanced Program Design--Summary of array methods