On Sun, Mar 20, 2011 at 3:49 PM, Andrew Dupont <mozi...@andrewdupont.net> wrote:
>
>> BTW, if you know that a property name is foo, why would you ever code 
>> obj["foo"] instead of obj.foo?
>
> The proposal strongly implies that the `private` declaration affects only "a 
> property name on the right of . or the left of : in an object initialiser." 
> Does it also affect bracket notation? In other words:
>
> private foo;
> obj.foo = 42;
> obj['foo'] === obj.foo; // true or false?

Assuming that we hadn't previously set obj['foo'], then false.

> If the answer is `false`, that's your answer for why I'd ever code 
> `obj['foo']` instead of `obj.foo`. If the answer is `true`, then that answers 
> one of the questions I was asking earlier; but it also means that there's no 
> way to get around the fact that the `private` declaration is "shadowing" any 
> possible use of a public property name called `foo` in the same lexical scope.
>



-- 
sam th
sa...@ccs.neu.edu
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to