Is there a general way in JavaScript / jQuery for checking all kinds of empty / null / null values, just like php?
No. In PHP, values converted to booleans give different results than in JavaScript. Thus, you cannot do this exactly like PHP does.
Why not be (a little more) explicit about it, which makes it easier to understand the code?
// falsy value (null, undefined, 0, "", false, NaN) OR "0"
if (!val || val === '0') { }
source
share