re: How to Check if Object is Empty in JavaScript VIEW POST


A typical programming practice is to set your object variable as undefined at first, so that comparison becomes much simpler for that later in code. All you have to do is:

var foo = undefined;
if (foo===undefined) doSomething();

The same holds true when you return a function value, return either a boolean or undefined as a falsy value to avoid trouble latter.

Code of Conduct Report abuse