Skip to content

Spot splice vs slice Mistake

Find the Mistake Medium
workbench

Question

This code is supposed to create a copy of part of the array without modifying the original, but it modifies the original. What is wrong?

Code

                  const original = [1, 2, 3, 4, 5];
const copy = original.splice(1, 3);
console.log(original);
console.log(copy);
                

Related Resources

Related Lessons

Related Reference

Look up unfamiliar terms

A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.

View glossary

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

Build real projects

Apply what you learned by building guided projects with starter code and solutions.

View projects

← Back to topic