Any opinions about adding a Ruby-like ||= operator to EcmaScript?
claude.pache at gmail.com
Wed Jul 29 12:25:55 UTC 2015
> Le 29 juil. 2015 à 13:23, Behrang Saeedzadeh <behrangsa at gmail.com> a écrit :
> For example:
> obj.property ||= "value";
> This would only assign "value" to obj.property if property is undefined or null.
For me, that syntax suggests strongly: Assign `value` to `obj.property` if `obj.property` is falsy. I'd rather want to write:
obj.property ??= value
where `??` could also be used as binary operator with the semantics you've guessed.
> Best regards,
> Behrang Saeedzadeh
> es-discuss mailing list
> es-discuss at mozilla.org
More information about the es-discuss