Every ES6 Array method you must know to be a JavaScript Expert

preview_player
Показать описание
We go through the 30 most important new and existing ES6 methods you need to be a true JavaScript expert.

Creating & Merging
concat(): Merge two or more arrays, and returns a new array
fill(): Fill the elements in an array with a static value
from(): Creates an array from an object

Foreach vs Map
forEach(): Calls a function once for each array element
map(): Creates a new array with the results of calling a function for each array element

Testing & Filtering
filter(): Creates a new array with all elements that pass the test in a testing function
every(): Checks if every element in an array passes a test in a testing function
isArray(): Determines whether the passed value is an array
some(): Checks if any of the elements in an array passes the test in a testing function

Reducers
reduce(): Reduce the values of an array to a single value (from left-to-right)
reduceRight(): Reduce the values of an array to a single value (from right-to-left)

Search & Find
find(): Returns the value of the first element in an array that pass the test in a testing function
findIndex(): Returns the index of the first element in an array that pass the test in a testing function
includes(): Determines whether an array includes a certain element
indexOf(): Search the array for an element and returns its first index
lastIndexOf(): Search the array for an element, starting at the end, and returns its last index

Pushing & Popping
pop(): Removes the last element from an array, and returns that element
push(): Adds one or more elements to the end of an array, and returns the array's new length
shift(): Removes the first element from an array, and returns that element
unshift(): Adds new elements to the beginning of an array, and returns the array's new length

Slice vs Splice
slice(): Selects a part of an array, and returns the new array
splice(): Adds/Removes elements from an array

Sorting
sort(): Sorts the elements of an array
copyWithin(): Copies part of an array to another location in the same array and returns it
reverse(): Reverses the order of the elements in an array

Display
join(): Joins all elements of an array into a string
toString(): Converts an array to a string, and returns the result

Iterators
entries(): Returns a key/value pair Array Iteration Object
keys(): Returns an Array Iteration Object, containing the keys of the original array
values(): Returns an Array Iteration Object, containing the values of the original array

---

-~-~~-~~~-~~-~-
Please watch: "Reviewing the top 5 tools you need to know to create web component in 2020"
-~-~~-~~~-~~-~-
Рекомендации по теме
Комментарии
Автор

Thanks for this. Really helpful. Love from Nigeria.

ajimahifeanyi
Автор

What plugin are you using to show the objects and arrays when you type the name?

JayWolters
welcome to shbcf.ru