var a = undefined;
var a = null;
a变量分别被赋值为undefined和null,这两种写法几乎等价。
undefined和null在if语句中,都会被自动转为false
if (!undefined)
console.log(‘undefined is false’);
if (!null)
console.log(‘null is false’);
if(true){
一定会执行里边的代码
}
var a = undefined;
var a = null;
a变量分别被赋值为undefined和null,这两种写法几乎等价。
undefined和null在if语句中,都会被自动转为false
if (!undefined)
console.log(‘undefined is false’);
if (!null)
console.log(‘null is false’);
if(true){
一定会执行里边的代码
}