Subj : Re: SeaMonkey: Global properties To : netscape.public.mozilla.jseng From : Brendan Eich Date : Wed Mar 05 2003 03:12 pm Anatoly Kochergin wrote: > from js console: > ----------------------------- > >a=1 > 1 > >a.a=1 > 1 The number 1 stored in the global property (or global variable, if you like) a is here wrapped with an instance of the Number class, as if you wrote Number(1).a = 1. That temporary object then has a property named 'a' set to the value 1, after which the temporary Number instance becomes garbage to be collected. > > >a.a.a=1 > TypeError: a.a has no properties Since the Number wrapper for the value 1 stored in a became unreachable, and liable to be garbage-collected, immediately after its 'a' property was set to 1, your new reference here to a.a simply repeats the process, and finds no such property named 'a' in the new, second, and different Number temporary instance wrapping the value 1 (which was and is the value stored in the global 'a' property). A reference to an undefined property results in the undefined value, which itself has no properties. That's what the TypeError is telling you. /be > > ----------------------------- > > How can second line be successfull? There is no "a" object after the > first line, isn't it? > > Best Regards, > Anatoly > .