Technology · 24 cards · beginner

JavaScript Array Methods

Learn the 24 most-used JavaScript array methods with flashcards: what each method returns, whether it mutates the array, and a one-line example. Written from the MDN documentation and testable in any browser console.

Who this deck is for

Developers learning JavaScript, bootcamp students, and anyone preparing for frontend interviews.

Scope

Covers the 24 most commonly used Array instance methods in modern JavaScript (ES2023 and earlier). Does not cover typed arrays, async iteration, or the Array constructor’s static methods beyond Array.isArray, Array.from and Array.of.

Review

Flashcard Maker engineering — every example was executed in a browser console and checked against MDN before publishing. Last reviewed: 2026-08-13.

Sources
Card 1 of 24Click the card to flip

Want spaced-repetition scheduling for this material?

Create a free account, build your own deck in the editor and study it on a schedule based on what you forget.

Start free

All 24 cards in this deck

  1. 1. What does `array.push(item)` do, and what does it return?
    Adds one or more items to the END of the array (mutates it) and returns the new length. `[1,2].push(3)` → returns `3`, array is `[1,2,3]`.
  2. 2. What does `array.pop()` do, and what does it return?
    Removes the LAST element (mutates) and returns that element, or `undefined` for an empty array. `[1,2,3].pop()` → returns `3`.
  3. 3. What does `array.shift()` do?
    Removes the FIRST element (mutates) and returns it. `[1,2,3].shift()` → returns `1`, array is `[2,3]`.
  4. 4. What does `array.unshift(item)` do?
    Adds one or more items to the FRONT of the array (mutates) and returns the new length. `[2,3].unshift(1)` → array is `[1,2,3]`.
  5. 5. Does `array.map(fn)` mutate the array? What does it return?
    No — it returns a NEW array with `fn` applied to every element. `[1,2,3].map(x => x * 2)` → `[2,4,6]`.
  6. 6. What does `array.filter(fn)` return?
    A NEW array containing only the elements for which `fn` returned a truthy value. `[1,2,3,4].filter(x => x % 2 === 0)` → `[2,4]`.
  7. 7. What does `array.reduce(fn, initialValue)` do?
    Runs `fn(accumulator, element)` over the array to build a single value. `[1,2,3].reduce((sum, x) => sum + x, 0)` → `6`.
  8. 8. Difference between `array.find(fn)` and `array.filter(fn)`?
    `find` returns the FIRST matching element (or `undefined`); `filter` returns ALL matches as a new array. `[1,2,3].find(x => x > 1)` → `2`.
  9. 9. What does `array.findIndex(fn)` return when nothing matches?
    It returns `-1`. Otherwise it returns the index of the first matching element. `[5,10].findIndex(x => x === 10)` → `1`.
  10. 10. What does `array.includes(value)` return?
    `true` if the array contains the value (using SameValueZero equality, so it finds `NaN`), else `false`. `[1,2].includes(2)` → `true`.
  11. 11. Difference between `array.indexOf(value)` and `array.includes(value)`?
    `indexOf` returns the first index or `-1` and cannot find `NaN`; `includes` returns a boolean and does find `NaN`.
  12. 12. What does `array.slice(start, end)` return? Does it mutate?
    A NEW shallow-copied sub-array from `start` up to but NOT including `end`; the original is untouched. `[1,2,3,4].slice(1,3)` → `[2,3]`.
  13. 13. What does `array.splice(start, deleteCount, ...items)` do?
    MUTATES the array: removes `deleteCount` elements at `start`, optionally inserts `items`, and returns the removed elements. `[1,2,3].splice(1,1)` → returns `[2]`, array is `[1,3]`.
  14. 14. What does `array.concat(other)` return?
    A NEW array joining the original with the given arrays/values; no mutation. `[1].concat([2,3])` → `[1,2,3]`.
  15. 15. What does `array.join(separator)` return?
    A string of all elements joined by the separator (default comma). `["a","b"].join("-")` → `"a-b"`.
  16. 16. Does `array.reverse()` return a new array?
    No — it reverses IN PLACE (mutates) and returns the same array. Use `array.toReversed()` (ES2023) for a non-mutating version.
  17. 17. What is the default sort order of `array.sort()` and its big gotcha?
    It sorts IN PLACE by converting elements to STRINGS, so `[10, 2, 1].sort()` → `[1, 10, 2]`. Pass a comparator: `arr.sort((a, b) => a - b)`. Non-mutating version: `toSorted()`.
  18. 18. What does `array.flat(depth)` do?
    Returns a NEW array with nested arrays flattened to the given depth (default 1). `[1,[2,[3]]].flat()` → `[1,2,[3]]`.
  19. 19. What does `array.flatMap(fn)` do?
    Maps each element with `fn`, then flattens the result one level. `[1,2].flatMap(x => [x, x * 10])` → `[1,10,2,20]`.
  20. 20. What do `array.some(fn)` and `array.every(fn)` return?
    Booleans: `some` is `true` if AT LEAST ONE element passes `fn`; `every` is `true` only if ALL elements pass. Both stop early when the answer is decided.
  21. 21. What does `array.forEach(fn)` return, and can you break out of it?
    It always returns `undefined`, and you cannot `break` out of it — use a `for...of` loop (or `some`) when you need early exit.
  22. 22. What does `array.at(-1)` return?
    The LAST element — `at` accepts negative indexes counting from the end. `[1,2,3].at(-1)` → `3`.
  23. 23. What does `Array.isArray(value)` check, and why not `typeof`?
    It reliably tells whether a value is an array. `typeof []` returns `"object"`, so `typeof` cannot distinguish arrays from other objects.
  24. 24. What does `Array.from(iterable, mapFn?)` do?
    Creates a NEW array from any iterable or array-like value, optionally mapping each element. `Array.from("abc")` → `["a","b","c"]`.

Good to know

  • All examples run as-is in a browser console or Node.js.
  • “Mutates” means the method changes the original array instead of returning a new one.

Found an error, or content you believe violates our Terms? Email support@onlineflashcardmaker.com — we fix verified reports and update the review date.

Related