这是我正在测试的代码——
工作正常
document.write( 1 && undefined ); // prints undefined
document.write( 1 && 3 ); // prints 3
document.write( 1 && true ); // prints true
抛出错误
document.write( 1 && NULL ); // throws Error
为什么使用 NULL 会抛出错误,尽管它甚至对于未定义的情况也有效
虽然我测试了 typeofNULL
和它的给予undefined
但它仍然不起作用。让我知道这一点。 (OOP 编程新手)
NULL
不存在,试试这个
try {
document.write( 1 && NULL );
} catch ( e) {
document.write( 1 && null );
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)