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;
Object.isNumber(+chr3 )  --> FALSE  // Note that : +'15a9' = NaN but
parseInt('15a9', 10) = 15;
Object.isNumber(+chr4 )  --> FALSE  // Note that : +'159a' = NaN but
parseInt('159a', 10) = 159;


Sorry for double post...

A_r_e_s

On Sep 5, 1:07 pm, EMoreth <[EMAIL PROTECTED]> wrote:
> 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- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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