我刚刚执行控制台以下:为什么`typeof false || undefined`返回“布尔”
typeof false || undefined // "boolean"
虽然我希望它返回“未定义”,因为
typeof undefined // "undefined"
为什么会返回“布尔” ?如果之前评估为falsey值,那么OR
运算符是否应该返回最后一个参数?所以false || undefined
返回undefined
和typeof
执行对undefined
?
'typeof运算FALSE'返回字符串'boolean'这是真的 – Maxx
@Maxx,我知道,我的问题是在最后一段 –
'typeof(false || undefined)'是你的解决方案 – Maxx