使用JavaScript如果语句在false上运行?
我使用test();
但在控制台中我得到 “其中没有设置” 功能
function test(variable)
{
if(variable != 'undefined')
{
console.log('variable is not set');
console.log('variable', where);
}
}
我把它叫做“其中被设置为未定义”
为什么?
更新 这个函数不是我实际使用的。
如果变量未定义,该函数不应该做任何事情。
该示例显示if语句不起作用。
但是这个问题实际上我如果variable != 'undefined'
代替variable != undefined