Boolean(value) 是把值转换成Boolean类型
example
var b1 = Boolean("");//返回false,空字符串
var b2 = Boolean("s");//返回true,非空字符串
var b3 = Boolean(0);//返回false,数字0
var b4 = Boolean(1);//返回true,非0数字
var b5 = Boolean(-1);//返回true,非0数字
var b6 = Boolean(null);//返回false
var b7 = Boolean(undefined);//返回false
var b8 = Boolean(new Object());//返回true,对象
function test() { alert(' emmm..'); } console.log(typeof test); console.log(Boolean(test));
typeof判断test为function
Boolean转换为true
function test(can) { alert(' emmm..'); } console.log(typeof test()); console.log(Boolean(test()));
typeof判断test()方法为undefined
Boolean转换为false