splice(index, count, ...items): remove or insert anywhere.
slice(), concat(), join(), includes(), indexOf()
Iteration methods
forEach(): run a function for each element.
map(): create a new array by transforming each element.
filter(): keep elements that pass a test.
reduce(): combine all elements into one value.
find(), some(), every()
sort(): pass a compare function for numbers: (a, b) => a - b.
💡 Key Takeaways: JavaScript Array Methods
Mastering JavaScript Array Methods helps you write clean and reliable JavaScript code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
JavaScript Array Methods Code Example
JavaScript
<pre id="out"></pre>
<script>
const log = (...a) => document.getElementById("out").textContent += a.join(" ") + "\n";
const marks = [72, 95, 58, 88, 64];
log("Doubled:", marks.map(m => m * 2));
log("Passed (>= 65):", marks.filter(m => m >= 65));
log("Total:", marks.reduce((sum, m) => sum + m, 0));
log("First above 90:", marks.find(m => m > 90));
log("Sorted:", [...marks].sort((a, b) => a - b));
const list = ["a", "b"];
list.push("c");
list.unshift("z");
list.splice(2, 1, "X");
log("List:", list.join(" - "));
</script>
Free sign-in required · Google login available
JavaScript Array Methods Practice Exercises
Check what you learned in “JavaScript Array Methods”.
/ 3 solved
Fill in the blank
Keep only numbers greater than 10.
const big = nums.(n => n > 10);
✓ Correct!Not quite. Try again.
Multiple choice
Which method adds an element to the end of an array?
✓ Correct!Not quite. Try again.
Code challenge
Use map() to double every number and log the result joined with commas.
Write the code in the live editor. Your answer is checked automatically.