ES6 contains an array of all methods

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_45601379/article/details/100588824

      Learning Tonight "ES6 standard entry (3rd Edition)" Chapter 8 - extension of the array and found a lot about the array of methods have almost forgotten quickly electricity at night to charge.

1. arr.push () length additive element from the rear, the return value is added after the array

Here Insert Picture Description

2. arr.pop () to remove elements from the back, is only one element of the return value is deleted

Here Insert Picture Description

3. arr.shift () to remove elements from the front, can only remove a return value is removed elements

Here Insert Picture Description

4. arr.unshift () length from the foregoing additive element, the return value is added after the array

Here Insert Picture Description

5. The arr.splice (I, n) deleted after n elements starting from I (index value), the return value is deleted element

Here Insert Picture Description

6. The arr.concat () new array connected to two arrays, connected to the return value

Here Insert Picture Description

7. The str.split () will be converted to an array of strings

Here Insert Picture Description

8. The arr.sort () to sort the array, good return value is an array of rows, the default is sorted by the leftmost digit

Here Insert Picture Description

9. The arr.reverse () array reversed, the return value is an array of the inverted

Here Insert Picture Description

10. The arr.slice (start, end) cut index values start to end of the array index value, the index does not contain the end value, the return value is an array of cut out

Here Insert Picture Description

11. The arr.forEach (the callback) to iterate, no return

callback parameters: value - the current value of the index, index - the index, array - the original array

Here Insert Picture Description

12. The arr.map (the callback) through the array, a new array Returns

Here Insert Picture Description

13. arr.filter (the callback) with arrays, returns an array to meet the requirements of

Here Insert Picture Description

14. A arr.every (the callback) based on judgment condition whether the whole element of the array is satisfied, if yes return ture

Here Insert Picture Description

15. A arr.some () based on the determination condition element, whether there is an array satisfied, if a return to meet ture

Here Insert Picture Description

16. A arr.reduce (the callback, the initialValue) iterative array all, accumulators, each value (left to right) were combined in the array, a finally calculated value

callback parameters: previousValue Required - callback return value on a first call, or starting values ​​(initialValue); currentValue Required - array item currently processed array; optional index - entry in the current array the index values ​​in the array; optional array - source array; initialValue: optional - initial value

Here Insert Picture Description

17. A arr.reduceRight (the callback, the initialValue) as in arr.reduce () function, except that, reduceRight () from the forward end of the array of the array do accumulate items in the array

Here Insert Picture Description

18. A arr.indexOf () to find an element index value, if repeated, the index value is found in the first return; if not, it returns -1

Here Insert Picture Description

19. The arr.lastIndexOf () As with arr.indexOf () function, except that the look from the back

Here Insert Picture Description

20. The Array.from () two types of objects will be converted to an array of real

Here Insert Picture Description

21. A Array.of () for converting a set of values into an array

Here Insert Picture Description

22. The arr.copyWithin () within the current array, the array will copy the specified location to another location, the array will overwrite the original item, return to the current array

Parameters: target - Required index start position displaced from the array entries; start - optional index entry array is read from the start position, the default is 0, if negative, then read from right to left; end - optional index into an array of items in the position to stop reading, the default is Array.length, if it is negative, the reciprocal of

Here Insert Picture Description

23. The arr.find (callback) to find the first array of items qualifying

Here Insert Picture Description

24. The arr.findIndex (callback) to find the first qualifying array index value of the item

Here Insert Picture Description

25. A arr.fill (target, Start, End) the given value, a filled array, the original array will change after filling

Parameters: target - the element to be filled; Start - starts filling position - index; End - the terminating filled - the index (not including this position)

Here Insert Picture Description

26. A arr.includes () determines whether the array contains the given value

Here Insert Picture Description

27. The arr.keys () keys to iterate

Here Insert Picture Description

28. The arr.values () keys to iterate

Here Insert Picture Description

29. The arr.entries () key names and values through the array

Here Insert Picture Description

30. A arr.join () the group of elements of the array from a string (the original array unchanged), Comma Separated by default, which only receives a parameter: delimiters

Here Insert Picture Description

Author: Yaphets.Lee

Please indicate the source, thanks!

Guess you like

Origin blog.csdn.net/weixin_45601379/article/details/100588824