On Mar 20, 2011 3:34 PM, "Kyle Simpson" <get...@gmail.com> wrote: >> >> BTW, if you know that a property name is foo, why would you ever code obj["foo"] instead of obj.foo? > > > The most obvious reason is if the name of the property contains a character which cannot be an identifier character in the property name... like a unicode character, for instance.
"Unicode characters" (non-ASCII) other than whitespace are pretty much all permissible in property names via dot syntax, FWIW. Lambda and pi are the most common, though I've seen other math/greek as well. A property name with whitespace is not expressible with dot syntax, but unlikely to be used except in object-as-hashtable cases. > Are we talking about the difference between obj['foo'] and obj[foo]? I think perhaps that was a subtle shift in this conversation that I missed until just now? > > Without private names, is there (and what is it?) an important distinction between: > 1. obj[foo] and obj.foo; AND > 2. obj['foo'] and obj.foo The former case of #1 refers to a property named by the value of the variable |foo|. All other cases refer to a property named "foo". So the cases in #2 are equivalent, but the ones in #1 are not. Mike
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss