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.
我想弄清楚数组是否为空。我试过了,但它不起作用。
a = [] if a == [] alert "empty"
我知道我可以检查数组的长度,但很好奇为什么这不起作用。
数组没有直接的空检查。你可以做这样的事情:
a = [] alert("empty") unless a.length