Code
var product = "11"*"11";//121
var strToNumber = "123"-0;
var strToNumber = Number(string_value);
Number()函数只能转换10进制
一般用parseInt()函数
eg:
parseInt(3 blind mice);//return 3
parseFloat("3.14 meters!");//return 3.14
parseInt("12.34");//return 12
parseInt()还可以有另外的参数;
parseInt("11",2);//return 3
parseInt("ff",16);//return 255
Note:
If parseInt() or parseFloat() can not convert the specified string to a number ,it returns NaN
parseInt("eleven!");//return NaN
parseInt("$123");//return NaN
var product = "11"*"11";//121
var strToNumber = "123"-0;
var strToNumber = Number(string_value);
Number()函数只能转换10进制
一般用parseInt()函数
eg:
parseInt(3 blind mice);//return 3
parseFloat("3.14 meters!");//return 3.14
parseInt("12.34");//return 12
parseInt()还可以有另外的参数;
parseInt("11",2);//return 3
parseInt("ff",16);//return 255
Note:
If parseInt() or parseFloat() can not convert the specified string to a number ,it returns NaN
parseInt("eleven!");//return NaN
parseInt("$123");//return NaN