Java Reference
In-Depth Information
> 1000000..toString(36) // a million in base 36
<< "lfls"
Parsing Numbers
There is also a useful function called parseInt() that can be used to convert a string
representation of a numerical value back into an integer. You can specify the base of the
number you are trying to convert, for example:
parseInt("1010",2); // converts from binary, back to
decimal
<< 10
parseInt("omg",36);
<< 31912
parseInt("23",10);
<< 23
If a string starts with a number, the parseInt function will use this number and ignore
any letters that come afterwards:
var address = "221B Baker Street"
<< undefined
parseInt(address, 10)
<< 221
If you try to do this with the Number function, it returns NaN :
Number(address)
<< NaN
And if you use parseInt with a decimal, it will remove anything after the decimal point:
parseInt("2.4",10)
<< 2
Search WWH ::




Custom Search