Ducks, Rabbits, and Privacy

Kevin Smith khs4473 at gmail.com
Thu Jan 24 05:47:26 PST 2013


> Why would you use a square bracket notation rather than a . Property
> access notation?
>
> [] is typically only use when the property name is in a variable, which is
> not the case when you write your own object.
>

True - but for symbols, your only option is square brackets:

    var sym = new Symbol(), obj = {};
    obj[sym] = 42;

So if you go the private symbols route, then you're going to have *lots* of
square brackets.

{ Kevin }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130124/fc1f6b20/attachment.html>


More information about the es-discuss mailing list