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
Object.isNumber(nmb2)  --> FALSE
Object.isNumber(nmb3)  --> TRUE

I think that this should be the right behavior huh ??

EMoreth

On Sep 4, 8:34 am, kangax <[EMAIL PROTECTED]> wrote:
> 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 number (as you seem
> to want to do), you might try something like:
>
> function canConvertToNumber(n) {
>   return !isNaN(+n);
>
> };
>
> --
> kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to