conversiton to number doesn't work

前提是你 提交于 2019-12-02 14:50:54
var num = '10'; // num is a string

Number(num); // you've done nothing with the RESULT, num is unchanged
console.log(typeof(num));//string - because you haven't changed num

parseInt(num); // you've done nothing with the RESULT, num is unchanged
console.log(typeof(num));//string - because you haven't changed num

parseFloat(num, 10); // you've done nothing with the RESULT, num is unchanged
console.log(typeof(num));//string - because you haven't changed num

var num = '10'; // num is a string
var string = 'aklñjg';  string is a string


num = Number(num); // num is a Number
string = Number(string);// string is a Number (NaN (not a number) is a number!)
console.log(typeof(num));//number 
console.log(typeof(string));//number


num = parseInt(num); // num is a number
string = parseInt(string); // string is a number (NaN still a number)
console.log(typeof(num));//number
console.log(typeof(string));//number
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!