Working with prototype
importance: 5
Here’s the code that creates a pair of objects, then modifies them.
Which values are shown in the process?
let animal = {
jumps: null
};
let rabbit = {
__proto__: animal,
jumps: true
};
alert( rabbit.jumps ); // ? (1)
delete rabbit.jumps;
alert( rabbit.jumps ); // ? (2)
delete animal.jumps;
alert( rabbit.jumps ); // ? (3)
There should be 3 answers.
true
, taken fromrabbit
.null
, taken fromanimal
.undefined
, there’s no such property any more.