Array Methods
Master this topic with zero to advance depth.
Expert Answer & Key Takeaways
Mastering Array Methods is essential for high-fidelity technical architecture and senior engineering roles in 2026.
JavaScript Array Methods
JavaScript provides powerful methods to transform arrays. Understanding which methods mutate (change) the original array and which return a new array is critical for high-end engineering.
1. Basic Mutators
| Method | Action | Returns |
|---|---|---|
push() | Adds element to end | New length |
pop() | Removes last element | Removed element |
shift() | Removes first element | Removed element |
unshift() | Adds element to start | New length |
2. The Splice Method
The
splice() method can be used to add, remove, or replace elements at any position. It mutates the original array.const fruits = ["Banana", "Orange", "Apple"];
fruits.splice(2, 0, "Lemon", "Kiwi"); // At index 2, remove 0, add two items3. The Slice Method
The
slice() method copies a section of an array into a new array. It does NOT mutate the original.const fruits = ["Banana", "Orange", "Lemon", "Apple"];
const citrus = fruits.slice(1, 3); // Orange, Lemon4. Joining Arrays
concat(): Merges two or more arrays. Returns a new array.join(): Joins all array elements into a string.
const arr1 = ["Cecilie", "Lone"];
const arr2 = ["Emil", "Tobias"];
const children = arr1.concat(arr2);[!IMPORTANT] For modern 2026 state management (like React), favor non-mutating methods likeslice()or the spread operator[...]to maintain immutability.
Top Interview Questions
?Interview Question
Q:Difference between slice() and splice()?
A:
slice() is non-mutating and returns a copy of a piece of an array. splice() is mutating and changes the original array by adding or removing elements.
?Interview Question
Q:Which methods add/remove from the START of an array?
A:
shift() removes the first element, and unshift() adds an element to the first position.
?Interview Question
Q:What is the result of [1, 2].concat([3, 4]) vs [...[1, 2], ...[3, 4]]?
A:
Both result in [1, 2, 3, 4], but the spread operator approach is used more frequently in modern 2026 functional programming for its clarity and immutability.
Course4All Engineering Team
Verified ExpertSenior Full-Stack Engineers & V8 Experts
Our JavaScript and engine-level content is developed by a collective of senior engineers focused on high-performance web architecture and 2026 standards.
Pattern: 2026 Ready
Updated: Weekly
Found an issue or have a suggestion?
Help us improve! Report bugs or suggest new features on our Telegram group.