1.

How To Convert A String To A Number Using Javascript?

Answer»

You can use the parseInt() and parseFloat() methods. NOTICE that extra letters following a valid number are ignored, which is kinda wierd but convenient at times. 
parseInt("100") ==> 100
parseFloat("98.6") ==> 98.6
parseFloat("98.6 is a common temperature.") ==> 98.6
parseInt("AA") ==> Nan //Not a Number
parseInt("aa",16) ==> 170 //you can SUPPLY a radix or base

You can use the parseInt() and parseFloat() methods. Notice that extra letters following a valid number are ignored, which is kinda wierd but convenient at times. 
parseInt("100") ==> 100
parseFloat("98.6") ==> 98.6
parseFloat("98.6 is a common temperature.") ==> 98.6
parseInt("aa") ==> Nan //Not a Number
parseInt("aa",16) ==> 170 //you can supply a radix or base



Discussion

No Comment Found