11 important array methods in JavaScript

preview_player
Показать описание
Arrays are one of the most used elements in JavaScript. Today I’m covering 11 arrays methods that will help you work more effectively.
1. join() method : this method joins all the elements of the array and returns a string
2. push() method : this method adds a specific element at the end of the array
3. pop() method : this method removes the last element of an array
4. sort() method: this method arranges all the elements of the array in an ascending of descending way
5. forEach() method: this method goes through the entire array and does something to each element of the array without returning anything
6. map() method: this method is similar to the forEach method but the difference is that this map() method returns a new array after applying something to all the elements of that array
7. slice method (): this method cuts a certain part of an array and returns that part in a new array
8. shift method () : this method removes the first element of an array
9. unshift method (): this method adds an element at the beginning of the array
10. indexOf method (): this method checks for the location of a specific element in the array and returns its position or -1 if the element is not found
11. Find method (): this method goes through the array and tries to find a specific element, if found it returns that element, or that first element that matches the search , if there is no element, it returns undefined .

Рекомендации по теме
join shbcf.ru