shorthand notation for attribute creation?

2014-02-09 Thread Hemanth H.M
Something like `var foo = {}; foo.bar ||= 3` would be very useful. But not sure how something like `obj['name']['maxlength']` be reduced to shorthand check if 'name' is not defined. -- *'I am what I am because of who we all are'* h3manth.com http://www.h3manth.com *-- Hemanth HM *

Re: shorthand notation for attribute creation?

2014-02-09 Thread Andrea Giammarchi
notation for attribute creation? Unless I misunderstood your idea, `||=` makes me naturally think about `+=` so if `i += n;` means `i = i + n` then `o.name ||= value` means `o.name = o.name || value` and this would be, according with all these years in ES3, the least surprising behavior

Re: shorthand notation for attribute creation?

2014-02-09 Thread Brendan Eich
[mailto:es-discuss-boun...@mozilla.org] On Behalf Of Andrea Giammarchi Sent: Sunday, February 9, 2014 15:29 To: Hemanth H.M Cc: es-discuss Subject: Re: shorthand notation for attribute creation? Unless I misunderstood your idea, `||=` makes me naturally think about `+=` so if `i += n;` means `i = i

Re: shorthand notation for attribute creation?

2014-02-09 Thread Hemanth H.M
Giammarchi Sent: Sunday, February 9, 2014 15:29 To: Hemanth H.M Cc: es-discuss Subject: Re: shorthand notation for attribute creation? Unless I misunderstood your idea, `||=` makes me naturally think about `+=` so if `i += n;` means `i = i + n` then `o.name ||= value` means `o.name