typeof undefined;// undefined typeof null; // object typeof {}; // object typeof []; // object typeof true; // boolean typeof 123; // number typeof '123'; // string typeof console.log ; // function
==:只看数值是否相等 (强制类型转换)
100=='100' //true 0==' ' //true undefined==null //true
if(有六种会转化为false)
0 NaN ' ' null undefined false
只有两种情况下可以用==(对象或者参数一定要定义):
看一个对象的属性是否存在:
var obj={}; if(obj.a==null) {};
看一个函数中的参数是否存在
function(a,b){ if(a==null) {} }