JavaScript Array Methods

JavaScript Tutorial

JavaScript Array Methods

In JavaScript Array Methods provides many built-in array methods to add, remove, search, sort, and manipulate data efficiently.

 1. push() – Add Item to End

Output:
["Apple", "Banana", "Mango"]

 2. pop() – Remove Last Item

Output:
["Apple", "Banana"]

 3. shift() – Remove First Item

Output:
["Banana"]

 4. unshift() – Add Item to Beginning

Output:
["Orange", "Banana"]

 5. splice() – Add or Remove Items

Output:
[10, 20, 40]

Add using splice:

 6. slice() – Copy Part of Array

 7. concat() – Join Arrays

 8. indexOf() – Find Position

 9. includes() – Check If Exists

 10. sort() – Sort Alphabetically or Numerically

Sort numbers properly:

 11. reverse() – Reverse Array

 12. join() – Convert Array to String

 13. map() – Create New Array by Applying Function

 14. filter() – Returns Only Matching Elements

 15. reduce() – Calculate a Single Result

Example: sum of numbers

 16. forEach() – Loop Through Array

 Summary Table

MethodAction
push()Add to end
pop()Remove last
shift()Remove first
unshift()Add first
splice()Add/remove items
slice()Copy portion
concat()Combine arrays
indexOf() / includes()Search items
sort() / reverse()Modify order
join()Convert to string
map()Transform array
filter()Filter values
reduce()Compute single result
forEach()Loop through items

You may also like...