I\'ve been reading \"Javascript: The Good Parts\" by Douglas Crockford - and while it\'s a bit extreme, I\'m on board with a lot of what he has to say.
In chapter
I think what's happening is that when you create person2
, the sex
and info
properties of it refer to those in nestObj
. When you reference person2.info
, since person2
doesn't redefine the info
property, it goes through to the prototype and modifies the object there.
It looks like the "right" way to do it is the way you build person3
, so that the object has its own info
object to modify and doesn't go up to the prototype.
I'm reading the book too (slowly), so I sympathize with you. :)