Decimal comparisons

Garrett Smith dhtmlkitchen at gmail.com
Fri Sep 19 16:29:36 PDT 2008


On Fri, Sep 19, 2008 at 9:39 AM, Brendan Eich <brendan at mozilla.org> wrote:
> On Sep 19, 2008, at 10:27 AM, Sam Ruby wrote:
>
>> On Fri, Sep 19, 2008 at 9:21 AM, Brendan Eich <brendan at mozilla.org>
>> wrote:
>>> On Sep 19, 2008, at 8:45 AM, Sam Ruby wrote:
>>>


> We've been around this block on the list. I'm with you: typeof 1.1m
> == "decimal" and we'll take chances with code that thinks it knows
> every result string that typeof might produce.
>

What is the best way to check if a value is numeric?

Existing code that uses:

  if(typeof x == "number") { ... }

- could be changed to:-

  if(typeof x == "number" || typeof x == "decimal") { ... }

- is this the proposed solution?

ES4 had something like:-
  if(x is Number){...}

Thank you,

Garrett

> /be


More information about the Es-discuss mailing list