> Le 10 mai 2016 à 09:44, G. Kay Lee <balancetraveller+es-disc...@gmail.com> a 
> écrit :
> 
> 
> Can't remember any instance where I've written something like `x = x || {}` 
> after the introduction of Default Parameters in ES6, so I don't see any 
> chance for me writing something like `x ||= {}` even if this thing somehow 
> makes its way in.

Some people do have use cases despite default arguments, see e.g. 
https://esdiscuss.org/topic/is-much-needed#content-4 
<https://esdiscuss.org/topic/is-much-needed#content-4>

> 
> The thing is, it's far more common to encounter codes like `x = y || {}`, and 
> then a new Default Operator would make sense due to the issue with falsy 
> values. So I'd throw my support behind an authentic Default Operator proposal 
> like `x = y ?? {}` 
> (http://wiki.ecmascript.org/doku.php?id=strawman:default_operator 
> <http://wiki.ecmascript.org/doku.php?id=strawman:default_operator>). But 
> definitely not `||=`.
> 

Agree. I wonder why people keep to reclaim a `||=` operator (with semantics 
inspired from binary `||`), when their use cases generally show that `??=` is 
more appropriate (with approximate semantics of: `if (a === undefined) a = b;`).

—Claude
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to