45   JS

如果一个变量等于以下情况

undefined
null
false
0
NaN
""
''

if 将会判断为false

但是,对于空数组和空对象,则会返回true

if([]){
console.log("empty array")
}

if({}){
console.log("empty object")
}



Leave a Reply

Your email address will not be published. Required fields are marked *