December 21, 2022
Estimated Post Reading Time ~

9 Javascript array methods you should master

9 Javascript array methods you should master



1. push() This method adds one or more elements to the end of an array and returns the new length of the array.



2. pop() This method removes the last element from an array and returns that element.



3. shift() This method removes the first element from an array and returns that element.



4. unshift() This method adds one or more elements to the beginning of an array and returns the new length of the array.



5. indexOf(): This method searches the array for the specified item and returns its position.



6. slice() This method returns a shallow copy of a portion of an array into a new array object.



7. splice() This method adds/removes elements from an array and returns the removed items.



8. forEach() This method executes a provided function once for each array element.






By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.