Ready. Start with one instruction.
Loading the learning workspace…
FROM YOUR FIRST INSTRUCTION TO A WORKING APPLICATION
Learn JavaScript from scratch through small working examples, visual experiments and complete projects. No account or AI key required.
Predict → Experiment → Build → Test → Explain
Ready. Start with one instruction.
Loading the learning workspace…
Objects have identity. Assigning original to shared gives two bindings access to the same object; updating shared.title is visible through original. Object spread creates a separate outer object, so its copied title stays First. This is a shallow copy: a nested object would still be shared unless separately copied. The strict identity comparison confirms that original and shared refer to the same object. Inspect both data values and identity when debugging mutation.
function solve(title) {
const original = { title: "First" };
const shared = original;
const copy = { ...original };
shared.title = title;
return { original: original.title, copy: copy.title, same: original === shared };
}
console.log(solve("Updated"));{"original":"Updated","copy":"First","same":true}Objects have identity. Assigning original to shared gives two bindings access to the same object; updating shared.title is visible through original. Object spread creates a separate outer object, so its copied title stays First. This is a shallow copy: a nested object would still be shared unless separately copied. The strict identity comparison confirms that original and shared refer to the same object. Inspect both data values and identity when debugging mutation.
function solve(title) {This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const original = { title: "First" };This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const shared = original;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const copy = { ...original };This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
shared.title = title;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
return { original: original.title, copy: copy.title, same: original === shared };Return the value of this exact expression to the caller. Follow its inputs using the concept explanation above.
}Close the current instruction block.
console.log(solve("Updated"));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
function solve(title) {
const original = { title: "First" };
const shared = original;
const copy = { ...original };
shared.title = title;
return { original: original.title, copy: copy.title, same: original === shared };
}
console.log(solve("Second"));{"original":"Second","copy":"First","same":true}Objects have identity. Assigning original to shared gives two bindings access to the same object; updating shared.title is visible through original. Object spread creates a separate outer object, so its copied title stays First. This is a shallow copy: a nested object would still be shared unless separately copied. The strict identity comparison confirms that original and shared refer to the same object. Inspect both data values and identity when debugging mutation.
function solve(title) {This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const original = { title: "First" };This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const shared = original;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const copy = { ...original };This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
shared.title = title;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
return { original: original.title, copy: copy.title, same: original === shared };Return the value of this exact expression to the caller. Follow its inputs using the concept explanation above.
}Close the current instruction block.
console.log(solve("Second"));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
function solve(title) {
const original = { title: "First" };
const shared = original;
const copy = { ...original };
shared.title = title;
return { original: original.title, copy: copy.title, same: original === shared };
}
console.log(solve(""));{"original":"","copy":"First","same":true}Objects have identity. Assigning original to shared gives two bindings access to the same object; updating shared.title is visible through original. Object spread creates a separate outer object, so its copied title stays First. This is a shallow copy: a nested object would still be shared unless separately copied. The strict identity comparison confirms that original and shared refer to the same object. Inspect both data values and identity when debugging mutation.
function solve(title) {This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const original = { title: "First" };This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const shared = original;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const copy = { ...original };This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
shared.title = title;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
return { original: original.title, copy: copy.title, same: original === shared };Return the value of this exact expression to the caller. Follow its inputs using the concept explanation above.
}Close the current instruction block.
console.log(solve(""));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
Repair the intentionally changed operation so the example produces the exact expected result. Then try the extension without copying the answer.
function solve(title) {
const original = { title: "First" };
const shared = original;
const copy = original;
shared.title = title;
return { original: original.title, copy: copy.title, same: original === shared };
}
console.log(solve("Updated"));function solve(title) {
const original = { title: "First" };
const shared = original;
const copy = { ...original };
shared.title = title;
return { original: original.title, copy: copy.title, same: original === shared };
}
console.log(solve("Updated"));Copy both the outer record and profile.
Which operation changed the result, why did it work, and what would you test next?
Use a different value that could expose a boundary or mistake. Predict the result first, run it, and explain how the concept would help in a small real application.
Related: Previous lesson Next lesson
100 lessons across 20 modules, covering variables, operators, strings, conditions, loops, functions, scope, arrays, objects, DOM, events, state, testing, asynchronous JavaScript and application development.