var str = '0.25';
How to convert the above to 0.25?
var str = '0.25';
How to convert the above to 0.25?
There are several ways to achieve it:
Using the unary plus operator:
var n = +str;
The Number
constructor:
var n = Number(str);
The parseFloat
function:
var n = parseFloat(str);