||= is much needed?
Tab Atkins Jr.
jackalmage at gmail.com
Thu Jun 14 11:19:51 PDT 2012
On Thu, Jun 14, 2012 at 11:01 AM, Brendan Eich <brendan at mozilla.com> wrote:
> We have a problem with || indeed. The question is whether the solution
> should equate null and undefined. CoffeeScript chose the
> conceal-the-difference path and it has users. The users who want null to be
> distinct from undefined are neither CoffeeScript users, nor || users (in
> their defaulting code). They must be doing === undefined test. That is rare
> too (not quite as rare as passing null instead of undefined as intentional
> default trigger in my experience).
> What is your reason for preferring === undefined over == null, since we have
> a dilemma and users often use an even looser (falsy, viz ||) test than ==
> null, but some use == null and others use === undefined, for the defaulting
I don't claim to be typical in cases like this, but my experience is
similar to Herby's - I use || most of the time just because it's short
and easy, but switch to "x === undefined" with a trinary if x might be
More information about the es-discuss