Adding & Removing Elements in JavaScript

From the JavaScript Array Methods cheat sheet · Array Manipulation · verified Jul 2026

Adding & Removing Elements

Methods to add and remove array elements

javascript
// Add/remove from end
arr.push(4, 5);    // Returns new length
arr.pop();         // Returns removed element

// Add/remove from start
arr.unshift(0);    // Returns new length
arr.shift();       // Returns removed element

// Add/remove anywhere
arr.splice(1, 2, 'a', 'b'); // At index 1, remove 2, add 'a', 'b'
🟢 Essential - Core array operations
⚠️ push/pop/shift/unshift MUTATE the array
💡 push/pop work on end (fast), shift/unshift on start (slower)
⚡ Use spread [...arr, item] for immutable operations
📌 All mutating methods return different values

Continue with JavaScript Array Methods

Save the full cheat sheet or work through every related task.

More JavaScript tasks

Back to the full JavaScript Array Methods cheat sheet