The foo.x refers to the property x to the object refered to by foo. However, foo = {n:2} assigns a completely new object to foo. x is indeed assigned to an object, but that object is immediately replaced by another object. The object with the x property isn’t referenced by anything anymore.