Sam Tobin-Hochstadt samth at
Fri Dec 14 05:08:12 PST 2012

On Fri, Dec 14, 2012 at 2:43 AM, Andreas Rossberg <rossberg at> wrote:
> On 14 December 2012 06:46, John-David Dalton
> <john.david.dalton at> wrote:
>>Axel Rauschmayer:
>>> Honest question: I have yet to see boxed values in practice. Are there any
>>> real use cases?
>> See Modernizr:
> I think not. And wrapping bools, like the above piece of code does, is
> a particularly bad idea, because JS says
>   (Object(false) ? 1 : 2)  ===  1

Fortunately, I think that bit of code never returns Object(false),
because the `if` fails first, and just plain `false` is returned.

Really, since objects are truthy, `new Boolean(bool)` there could be
replaced with `{}`.  Or, the whole body of the `if` could just be an
object literal.


More information about the es-discuss mailing list