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…
Destructuring extracts a named property into a local binding. Spread copies enumerable own properties to a new outer object, and the later active property overrides any earlier value from the spread. A method is a callable property of an object; formatter.label() invokes it. These constructs are useful for building a display model without mutating the input. Spread is shallow, and a method’s behavior still needs tests rather than an assumption based on its short syntax.
function solve(person) {
const { name } = person;
const copy = { ...person, active: true };
const formatter = { label() { return name + ": " + copy.active; } };
return formatter.label();
}
console.log(solve({"name":"Alex"}));Alex: true
Destructuring extracts a named property into a local binding. Spread copies enumerable own properties to a new outer object, and the later active property overrides any earlier value from the spread. A method is a callable property of an object; formatter.label() invokes it. These constructs are useful for building a display model without mutating the input. Spread is shallow, and a method’s behavior still needs tests rather than an assumption based on its short syntax.
function solve(person) {This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const { name } = person;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const copy = { ...person, active: true };This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const formatter = { label() { return name + ": " + copy.active; } };Return the value of this exact expression to the caller. Follow its inputs using the concept explanation above.
return formatter.label();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({"name":"Alex"}));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
function solve(person) {
const { name } = person;
const copy = { ...person, active: true };
const formatter = { label() { return name + ": " + copy.active; } };
return formatter.label();
}
console.log(solve({"name":"Mina","active":false}));Mina: true
Destructuring extracts a named property into a local binding. Spread copies enumerable own properties to a new outer object, and the later active property overrides any earlier value from the spread. A method is a callable property of an object; formatter.label() invokes it. These constructs are useful for building a display model without mutating the input. Spread is shallow, and a method’s behavior still needs tests rather than an assumption based on its short syntax.
function solve(person) {This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const { name } = person;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const copy = { ...person, active: true };This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const formatter = { label() { return name + ": " + copy.active; } };Return the value of this exact expression to the caller. Follow its inputs using the concept explanation above.
return formatter.label();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({"name":"Mina","active":false}));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
function solve(person) {
const { name } = person;
const copy = { ...person, active: true };
const formatter = { label() { return name + ": " + copy.active; } };
return formatter.label();
}
console.log(solve({"name":""}));: true
Destructuring extracts a named property into a local binding. Spread copies enumerable own properties to a new outer object, and the later active property overrides any earlier value from the spread. A method is a callable property of an object; formatter.label() invokes it. These constructs are useful for building a display model without mutating the input. Spread is shallow, and a method’s behavior still needs tests rather than an assumption based on its short syntax.
function solve(person) {This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const { name } = person;This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const copy = { ...person, active: true };This statement belongs to the operation described above. Compare its names, arguments and current state before advancing.
const formatter = { label() { return name + ": " + copy.active; } };Return the value of this exact expression to the caller. Follow its inputs using the concept explanation above.
return formatter.label();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({"name":""}));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(person) {
const { name } = person;
const copy = { ...person, active: false };
const formatter = { label() { return name + ": " + copy.active; } };
return formatter.label();
}
console.log(solve({"name":"Alex"}));function solve(person) {
const { name } = person;
const copy = { ...person, active: true };
const formatter = { label() { return name + ": " + copy.active; } };
return formatter.label();
}
console.log(solve({"name":"Alex"}));Use zero when points is absent.
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.