5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Primitives and References lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Copy a number, change the copy, and report the original.
Assign an object to a second name, change it, and report the first.
Spread the object so the original is left alone.
Spread an array, push to the copy, and report both lengths.
Show that a property changed inside a function is visible outside.
A plain assignment shares the object.
Pushing to the second name changes the first array too.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceTwo separate objects are never equal, however alike.
Replacing the whole object inside a function is not visible outside.
Spreading copies only the top level, so the inner object is shared.