FREE JAVASCRIPT PRACTICE
Which array changes?
Take a peek.
A JavaScript array methods quiz: three short output predictions about slice versus splice, map and mutation, and shared references. Choose an answer, then follow the values step by step.
Compare indexed arrays in the slice vs splice visualizer →
slice vs splice
What does this JavaScript print? Each output line is a separate console.log call.
const letters = ["a", "b", "c"];
console.log(letters.slice(1).join(""));
letters.splice(1, 1);
console.log(letters.join(""));A code-only card with the quiz link. No answers or personal results.
No signup. These three questions reuse the free starter set. Quiz answers stay on this page only; your saved puzzle progress is unchanged. Fixed examples, not a code runner. Website-visit and performance measurement still apply. Privacy & data.
Slice, splice, map: what to watch
- slice copies a range
slice(start, end)returns a new array without changing the original. The end index is excluded; omit it to copy to the end. This is a shallow copy: nested objects are still shared.- splice changes the original
splice(start, deleteCount, ...items)removes or inserts elements in place and returns an array of removed elements. Unlike slice’s end index, its second argument is a count.- map returns a new array
map(callback)collects the callback’s results. In this quiz the callback only multiplies numbers, so the original stays unchanged. A callback can still mutate objects or the source array: a new result array is not a guarantee of no side effects.- Assignment shares a reference
const second = firstdoes not copy an array. Both names refer to the same object, so changing an element through either name is visible through the other.constprevents rebinding, not changes to array contents.
Want another example? Predict push’s return value or explore const and mutation in the free starter set.
