Hi Andrew,
Thanks for your reply.
I understood. I have no problem with your answer.
I'll extend Object with isValidNumber() method to use it instead :)
Satoru
On Apr 11, 6:18 pm, Andrew Dupont <[EMAIL PROTECTED]> wrote:
> It depends on your perspective. "typeof NaN" returns "number" in
> JavaScript. NaN certainly doesn't fit into any of the other buckets.
>
> Others have suggested that NaN ought to make Object.isNumber return
> false. But unless we have a compelling reason to do so, I think we
> ought to make the function mirror "typeof" as much as possible. Doing
> so is, in my opinion, less surprising.
>
> Anyway, if anyone is bothered by this behavior, add something like
> this to your standard library:
>
> Object.isValidNumber = function(object) {
> return typeof object === 'number' && !isNaN(number) && number !==
> Infinity && number !== -Infinity;
>
> };
>
> Cheers,
> Andrew
>
> On Apr 11, 3:27 am, Satoru Moriwaki <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > Object.isNumber() returns true on NaN. I don't think that's true....
> > NaN is Not a Number so it's not a number... right?
>
> > By the way, I'm using Prototype 1.6.0.2.
>
> > Satoru
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---