 <p>This will not work as:</p> <pre><code>typeof null === 'object'; </code></pre> <p>So it will always return an object and hence your code will not work.</p> <p>Rather you can try:</p> <pre><code>if (myNull == null){ // your code here. } </code></pre> <p>Also can try as suggested by Scott, but the if else would be the other way round:</p> <pre><code>if (myNull){} </code></pre>