类型转换
1.parseInt(进制转换把demo看做16进制的数,转换为10进制)
var dome = 10;
var num = parseInt(demo,16);
console.log(typeof(num)+":"+num);
2.parseFloat(转换为浮点数)
var demo = 10;
var m = parseFloat(demo);
3.String(转化为字符串)
var demo = 10;
var n = String(demo);
console.log(typeof(n)+":"+n);
4.tostring(进制转换)
var demo = 10
var l = demo.toString(8);
console.log(typeof(l)+":"+l);
5.类型转换的应用(2进制转10进制再转16进制)
var num = 10000;
var test = parseInt(num,2);
var ans = test.toString(16);
console.log(test);
console.log(ans);