3-1 string,boolean—>number()只能识别纯数字的字符串
//string-->number
var str = "123";
var s = "123px";
var a = "";//空串或者全是空格的字符
console.log(Number(a)); //0
console.log(Number(str));//123
console.log(Number(s));//NaN
*console.log(Number(NaN));//NaN
// boolean-->number
console.log(Number(true)); //1
console.log(Number(false)); //0
3-2 string,number—>boolean()
//number-->Boolean()
// 特殊:0-->false;
var b = 0;
console.log(Boolean(b)); //false
//string-->Boolean()
// 特殊:"" -->false;
var d = "";
console.log(Boolean(d));//false
3-3 Any-string
String(); toString(); +"";
var a = 123;
var b = 45 + "";
console.log(a.toString());//"123"
console.log(String(a));//"123"
console.log(b);//"45"
3-4 Any-number
Number(); parseInt(); parseFloat();
var a = "12d3px";
var b = "12.34px"
console.log(parseInt(a));//12
console.log(parseFloat(b));//12.34
3-5 Any-boolean
boolean();