Question: how to check null and undefined in javascript?
Answer: Use typeof anyway with falsy power operator: Using typeof can be a helpful trick, because if a variable is undeclared, then trying to reference it will throw a ReferenceError . But, the typeof an undeclared value is undefined , so using typeof can be a good way to check for null , undefined , and undeclared variables.