How To Convert A String To A Number Using JavaScript

How To Convert A String To A Number Using JavaScript


  • 8 Mar, 2012

    We can use the parseInt() and parseFloat() methods in JavaScript to convert a string to a number or numeric value. Notice that extra letters following a valid number are ignored, which is kinda wierd but convenient at times.parseInt("100") ==> 100parseFloat("98.6") ==> 98.6parseFloat("98.6 is a common temperature.") ==> 98.6parseInt("aa") ==> Nan //Not a NumberparseInt("aa",16) ==> 170 //We can supply a radix or base

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.