This exercise explores the differences between value and reference in JavaScript. It demonstrates how primitive types like strings
and numbers
are copied by value, while arrays
and objects
are copied by reference.
Various techniques like slice()
, concat()
, spread syntax
, and Object.assign()
are used to create shallow copies and avoid unintentional mutations.
Open the browser console (F12) to follow the step-by-step explanation and outputs.