length = 0时,布尔值为false
比如在if判断时
const arr = []
if(arr.length){
console.log(1)
}
if(!arr.length){
console.log(2)
}
最后输出2
arr1 = []
console.log(arr1.length);
console.log(arr1.length === false);
console.log(arr1.length == false);
console.log(0 == false);
console.log(1 == true);
console.log(2 == true);
if(!arr1.length) console.log('!');
可见,0判断为false,1为true,但是===就不行了