1.string—>number
只能识别纯数字的字符串,其它字符输出NaN
示例:var str ="3";
var num = Number(str);
console.log(typeof num)
console.log(Number("3.0"))
console.log(Number("3.00"))
console.log(Number("3px"))//Nan 不是一个数字的意思
2.boolean—>number
Number()
只有两种输出方式:true--1;false--0;
示例:var b = true;
var f = false;
console.log(Number(b));
console.log(Number(f));
3.string—>boolean
Boolean()
“”为false(也就是“”之间不加任何东西),其他都为true
示例:var str = "good";
var s = "";
var t = "";
console.log(Boolean(str));
colnsole.log(Boolean(s));
console.log(Boolean(t));
4.number—>boolean
只有0为false,其他情况都为true
示例:var num = 0;
var n = -1;
var m = 1;
cosole.log(Boolean(num));
consol.log(Boolean(n));
console.log(Boolean(m))
5.any—>string
number,boolean--string
toString()
示例:var num = 10;
var t =true;
console.log(String(num))
console.log(t.toString)
6.any—>number
string-->number
1.能够识别纯数字的字符串
2.""," ",识别成0
3.NaN
boolean--number
true 1
false 0