1-1 string,boolean —> number
var str = 'w';
var num = Number(str);
console.log(typeof num);
console.log(Number('3.0'));
console.log(Number('3.00'));
console.log(Number('3px')); //NaN 不是一个数字
// 1.能够识别纯数字的字符串
// 2.""," " 识别成0
// 3.NaN
1-2 boolean—> number
// true = 1; false = 0;
var a = true;
var b = false;
console.log(Number(a));
console.log(Number(b));
1-3 string,number —-> boolean
// string,number ---> boolean
// Boolean();
// string --> boolean 特点:'' 没有空格的空字符串为false,其他都为true
var str = 'good'
var s = ' '
var t = ''
console.log(Boolean(str));
console.log(Boolean(s));
console.log(Boolean(t));
1-4 number —> boolean
// number --> boolean
// tips:是只有0为false,其他情况都为true
var num1 = 0
var n = -1
var m = 1
console.log(Boolean(num));
console.log(Boolean(n));
console.log(Boolean(m));
1-5 number,boolean —> string
number,boolean --> string
// String();
var num1 = 10
var t = true
console.log(String(num1));
console.log(String(t));
1-6 转化结果为:false
// 转化结果为:false
// number -- 0
// string -- ""
// unfefined
// NaN