Convert a string to a number
- A few ways, but one my personal favorites is
var number = "1";
1 === +number // will be true
- Other ways are:
Number(number);
parseInt(number, 10);
parseFloat(number);
Convert a string to a number
var number = "1";
1 === +number // will be true
Number(number);
parseInt(number, 10);
parseFloat(number);