CodePeek
Practice / ArraysBack to CodePeek

JavaScript References: Two names, one array

Puzzle 7 of 15 · References

Follow two variables assigned to an array, then an element update through one variable. Predict what the other variable reads. Choose an output below, then check the explanation. No signup needed. Browse puzzles by topic →

Arrays / ReferencesJavaScript
const first = [1, 2];
const second = first;
second[0] = 9;
console.log(first.join(","));

Predict the console output. Each line is a separate log.

What’s the output?

Choose the output

Starter puzzles 15