[Prototype-core] Re: isNumber or Not A Number ??

2008-09-05 Thread EMoreth
Thats why im asking if NaN should not be a number... Because this way we can test things like he said: var nmb1 = new String(159); var nmb2 = 159; var nmb3 = 159; Object.isNumber(+nmb1) -- TRUE Object.isNumber(+nmb2) -- TRUE Object.isNumber(+nmb3) -- TRUE Object.isNumber(nmb1) -- FALSE

[Prototype-core] Re: isNumber or Not A Number ??

2008-09-05 Thread EMoreth
And obviously : var chr1 = a159; var chr2 = 1a59; var chr3 = 15a9; var chr3 = 159a; Object.isNumber(+chr1 ) -- FALSE // Note that : +'a159' = NaN and parseInt('a159', 10) = NaN; Object.isNumber(+chr2 ) -- FALSE // Note that : +'1a59' = NaN but parseInt('1a59', 10) = 1;

[Prototype-core] Re: isNumber or Not A Number ??

2008-09-05 Thread EMoreth
Attention to the '+' symbol before the variables This plus signal attempts to convert a string to a number using the auto conversion feature of javascript so a '123' changes to a number when you try to make it positive with +'123' == 123; (The same way could be done with - signal but it would

[Prototype-core] Re: isNumber or Not A Number ??

2008-09-04 Thread Christophe Porteneuve
Станислав Анисимов a écrit : Shouldn't Object.isNumber('111') be true? Nope. '111' is a String. -- Christophe Porteneuve aka TDD [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core

[Prototype-core] Re: isNumber or Not A Number ??

2008-09-04 Thread kangax
On Sep 4, 5:18 am, Станислав Анисимов [EMAIL PROTECTED] wrote: Is't this a rigth way to define types: 111  is Integer and Number '111'  is Number and String 'a111' is String Only `111` is a number primitive. The rest two are plain strings. To find out if a value can be type-converted into a

[Prototype-core] Re: isNumber or Not A Number ??

2008-09-02 Thread kangax
On Sep 2, 9:25 pm, EMoreth [EMAIL PROTECTED] wrote: Could someone tell me why Object.isNumber(NaN) returns TRUE ?? Shouldnt this be false ?? This is a somewhat controversial issue. The trunk version actually returns false (by making sure `isFinite` returns a truthy value). -- kangax