Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 javascript 中,我有一个名为长度的变量。当我尝试测试if (length)javascript 时说它是真的,即使值为零。我应该使用什么语法而不是if (length)测试那里是否有变量?
if (length)
这就是javascript的工作原理。要测试变量是否为空,您只需使用此语法if (length != null) ...
if (length != null) ...