for-in statement: null and undefined

liorean liorean at
Thu Jul 3 12:25:11 PDT 2008

On 03/07/2008, Kent Hansen <khansen at> wrote:
>  By the way, in the ES4 reference implementation, iterating over strings
>  is a no-op as well; implementation bug, or are string properties not
>  enumerable in ES4? "X".hasOwnProperty(0) returns false, too.

IIRC, this is the way it goes: A string cannot have properties itself.
The temporary String object created when calling a method can have
properties, but that String object is never returned from one of the
ES3 (or to my knowledge ES4) methods and can thus only be returned
from custom methods on the String prototype. This means that you're
not likely to encounter a String object derived from a string unless
you have author code that persists the temporary. The index access on
a string doesn't work as property access but instead like a custom
catch-all getter.

>  [1]
>  [2]
>  [3]
>  [4]
>  [5]
David "liorean" Andersson

More information about the Es4-discuss mailing list