JavaScript Array Methods Explained: Complete Guide with Examples (2026)

In JavaScript, arrays are one of the most fundamental data structures. Understanding array methods allows you to write cleaner, more efficient, and more maintainable code.
This guide covers the most important JavaScript array methods with practical examples.
1. Adding and Removing Elements
These are the most basic operations when working with arrays.
push() β Add to the end
let arr = [1, 2];
arr.push(3); // [1, 2, 3]pop() β Remove from the end
arr.pop(); // [1, 2]unshift() β Add to the beginning
arr.unshift(0); // [0, 1, 2]shift() β Remove from the beginning
arr.shift(); // [1, 2]π Commonly used when implementing stacks or queues.
2. Iterating and Transforming Arrays
These are the most important methods in real-world development.
map() β Create a new array
let numbers = [1, 2, 3];
let doubled = numbers.map(x => x * 2);
// [2, 4, 6]filter() β Filter elements
let even = numbers.filter(x => x % 2 === 0);
// [2]reduce() β Aggregate values
let sum = numbers.reduce((a, b) => a + b, 0);
// 6forEach() β Iterate through elements
numbers.forEach(x => console.log(x));π The most important trio: map β filter β reduce
3. Searching in Arrays
find() β Return the first matching element
numbers.find(x => x > 1); // 2findIndex() β Return index
numbers.findIndex(x => x > 1); // 1includes() β Check existence
numbers.includes(2); // trueindexOf() β Find position
numbers.indexOf(2); // 14. Array Manipulation
slice() β Extract a portion (non-mutating)
numbers.slice(0, 2);splice() β Modify the array (mutating)
numbers.splice(1, 1); // remove 1 elementconcat() β Merge arrays
numbers.concat([4, 5]);5. Sorting and Reversing
sort()
numbers.sort((a, b) => a - b);reverse()
numbers.reverse();6. Converting Arrays
join()
numbers.join(", "); // "1, 2, 3"toString()
numbers.toString();7. Modern Methods (ES6+)
flat()
[1, [2, 3]].flat(); // [1, 2, 3]flatMap()
[1, 2].flatMap(x => [x, x * 2]);at()
numbers.at(-1); // last elementWhen Should You Use Each Method?
map() β Transform data
filter() β Select specific items
reduce() β Calculate totals or summaries
find() β Get a single matching item
forEach() β Loop without returning data
