1.string -> number
// Number() parseInt() parseFloat()
// string --> number
// 1.能够识别纯数字的字符串
// 2.""," " 识别成0
// 3.NaN
console.log(parseInt('13px'));//13
console.log(parseFloat('13.2222px'));//13.2222
console.log(Number("12.2"));//12.2
console.log(Number(''));//0
console.log(Number(' '));//0
console.log(Number('12px'));//NaN
2.boolean -> number
// boolean --> number
// true -> 1 false -> 0
console.log(Number(true));//1
console.log(Number(false));//0
3.any-boolean
// number--boolean
// 0 - false 1 - true
console.log(Boolean(0));
console.log(Boolean(1));
// string -- boolean
// ""(空字符串) - false
// " "(有空格的字符串) - true
console.log(Boolean(''));
console.log(Boolean(' '));
4.any - boolean
// 转为字符串的方法
// 1.String
// 2.toString
// 3. + ""
var a = 20
console.log(a);
console.log(String("10"));
console.log(a.toString());
console.log(a + "");