Confused about Setting Prototype Manually Challenge

Hi freeCoders,

I am a bit confused about the challenge below. When I practice it on developer tool’s console, the newly created instance (let’s say “zozo”) is still able to see the constructor property (zozo.constructor) even after manually setting the prototype of the constructor function “Animal” to an object literal. So it’s not undefined as mentioned in the example.

I don’t think the context is clear in this example. Can someone tell me what I am missing :thinking:

Thanks in advance :slightly_smiling_face:

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36.

Link to the challenge:

When assigning an new object with =, the original object is not necessarily overwritten. Rather, the variable just now points to the new object, but the object it was previously referring to might still be referred somewhere else.

For example, zozo's prototype is some object that Animal.prototype has a reference to (let’s call that ObjectA). Even after assigning a new object to Animal.prototype (let’s call that ObjectB), zozo still is prototype-linked to ObjectA. So zozo's constructor is preserved.

However, new objects created from new Animal() are now prototype-linked to ObjectB, which no longer has a constructor that refers back to the Animal function.

Thank you @kevcomedia. I already knew about the reference data types and how they work, so intuitively created a new instance from the constructor whose prototype set manually and saw there is no constructor anymore in __proto__.

Still, the example given here is misleading since it’s not talking about creating a new instance, it rather sounds like previously created instances will also be affected by setting the prototype manually. Or I didn’t get the point :grimacing:

But your answer helped me a lot. Thank you for your time!

Here is a good article about the topic:

Cheers,