The best way:
var str = "1"; var num = +str;
You also can:
var str = "1"; var num = Number(str);
or
var str = "1"; var num = parseInt(str,10); //for integer number var num = parseFloat(str); //for float number
DO NOT:
var str = "1"; var num = new Number(str);
Use parseInt only for a special case, for example
var str = "ff"; var num = parseInt(str,16);
source share