Weird behaviour while checking nulls in javascript array
<p>I have an array of numbers with nulls in. I want to get the number of non-null element count. My code:</p>

<pre><code>var arrayWithNulls = [null, 8, 3, null, 5, 0, 9];

var cleanArray = [];

for(i = 0; i &lt; arrayWithNulls.length; i++){ 
    if(arrayWithNulls[i])
        cleanArray.push(arrayWithNulls[i]);
}

console.log(cleanArray.length);
</code></pre>

<p>But I get 4 instead of 5 as result. What am i missing? </p>