var values = [
"-10",
16,
0xFF,
"0xFF",
"8e5",
3.1415,
+10,
0144,
"",
{},
NaN,
null,
true,
Infinity,
undefined
];
for( var index in values ) {
var v = values[ index ];
$( 'table' ).append( '<tr><td>'+v+'</td><td>'
+(!isNaN( v )?"true":"false")
+'</td><td>'
+($.isNumeric( v )?"true":"false")
+'</td></tr>' );
}
OUTPUT:
"-10",
16,
0xFF,
"0xFF",
"8e5",
3.1415,
+10,
0144,
"",
{},
NaN,
null,
true,
Infinity,
undefined
];
for( var index in values ) {
var v = values[ index ];
$( 'table' ).append( '<tr><td>'+v+'</td><td>'
+(!isNaN( v )?"true":"false")
+'</td><td>'
+($.isNumeric( v )?"true":"false")
+'</td></tr>' );
}
OUTPUT:
!isNaN() | $.isNumeric() | |
---|---|---|
-10 | true | true |
16 | true | true |
255 | true | true |
0xFF | true | true |
8e5 | true | true |
3.1415 | true | true |
10 | true | true |
100 | true | true |
true | false | |
[object Object] | false | false |
NaN | false | false |
null | true | false |
true | true | false |
Infinity | true | false |
undefined | false | false |
No comments:
Post a Comment