/Arrays & Array Methods
Concept
Medium

Arrays & Array Methods

1 min read

Arrays are ordered, zero-indexed, and dynamically sized. Mutating methods: push, pop, shift, unshift, splice, sort, reverse, fill. Non-mutating methods: concat, slice, join, flat, includes, indexOf, find, findIndex. Spread (...) copies or merges arrays. Destructuring extracts elements into variables. Arrays are objects — assignment copies the reference, not the values.

Practice Questions7

easy

Q1. What is the output? ```js const arr = [1, 2, 3]; arr.push(4); console.log(arr.length); ```


Select one answer before revealing.

medium

Q2. Which array method removes elements from an array and can insert new ones in their place?


Select one answer before revealing.

medium

Q3. What is the output? ```js const a = [1, 2, 3]; const b = [...a, 4, 5]; console.log(b); ```


Select one answer before revealing.

medium

Q4. What is the output? ```js const [first, , third] = [10, 20, 30]; console.log(first, third); ```


Select one answer before revealing.

medium

Q5. Which of the following array methods do NOT mutate the original array? (More than one answer may be correct.)


Select one answer before revealing.

medium

Q6. What is the output? ```js const nums = [3, 1, 2]; nums.sort(); console.log(nums); ```


Select one answer before revealing.

easy

Q7. What does `[1, 2, 3].includes(2)` return?


Select one answer before revealing.