 <p>If you want to check if a variable (say v) has been defined and is not null:</p> <pre><code>if (typeof v !== 'undefined' &amp;&amp; v !== null) { // Do some operation } </code></pre> <p>If you want to check for all falsy values such as: <code>undefined</code>, <code>null</code>, <code>''</code>, <code>0</code>, <code>false</code>:</p> <pre><code>if (v) { // Do some operation } </code></pre>