Number.isNaN

Yusuke Suzuki utatane.tea at gmail.com
Thu Dec 13 20:00:36 PST 2012


>
> The current draft spec [0] uses a ToNumber coercion and checks whether
> this results is NaN.  So "Number.isNaN(Object(NaN))" will return "true".

Global's isNaN uses ToNumber, but Number.isNaN doesn't do it because type
coercion makes confused result, such as `isNaN(Object(NaN))` => true [0]

So "Number.isNaN(Object(NaN))" will return "false" in latest draft and
"isNaN(Object(NaN))"
will return "true".

[0] http://wiki.ecmascript.org/doku.php?id=harmony:number.isnan



On Fri, Dec 14, 2012 at 12:50 PM, Luke Hoban <lukeh at microsoft.com> wrote:

> >> From: es-discuss-bounces at mozilla.org [mailto:
> es-discuss-bounces at mozilla.org] On Behalf Of John-David Dalton
> >> Subject: Number.isNaN
>
> >> I noticed that ES6  `Number.isNaN` checks `Type(number)` of Number,
> would it make sense to instead check that the [[BuiltinBrand]] is
> BuiltinNumberWrapper similar to `Array.isArray`'s check. This would also
> allow `Number.isNaN(Object(NaN))` to return `true`. Thoughts?
>
> The current draft spec [0] uses a ToNumber coercion and checks whether
> this results is NaN.  So "Number.isNaN(Object(NaN))" will return "true".
>
> Luke
>
> [0] http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
Regards,
Yusuke Suzuki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121214/e5b0f4f0/attachment.html>


More information about the es-discuss mailing list