Subj : Re: Strange Rhino NativeString behavior To : netscape.public.mozilla.jseng From : Matt McShane Date : Sun Oct 24 2004 08:20 pm Igor Bukanov wrote: > You hit here JavaScript discrepancy about primitive type != object. > ECMAScript standard effectively states that x.y should be implemented > via converting x to object and then accessing its properties. If x is > string, it is converted using new String(x) so your last example is > equivalent to: > > var msg = "Hello, world." > (new String(msg)).someAttribute = "xyz" > (new String(msg)).myFunc() //prints o.m.j.UniqueTag@1027b4d: NOT_FOUND > > Thus any property assignment to primitive string is useless operation > since the temporary created String object will be lost. > > Regards, Igor > > Thank you, Igor, that certainly explains things. And here I didn't even know ECMAScript had primitives. Although I have to ask, /why/ does a scripting lanugage need primitives? .