how to remove null, undefined, NaN, 0s, falses and empty string from an array in JavaScript?
<p>I wrote a script to remove any null, undefined, 0, false or empty string value using .splice(), but the code has only removed NaN and 0s.</p>

<p>Here is what I tried:</p>

<pre><code>function remove(arr){ // input [NaN, 0, 15, false, -22, '',undefined, 47, null]
    var bin = [];
    for (var i =0; i&lt;arr.length; i++){
        if (arr[i] == (NaN || 0 || false || "" || undefined || null)){
            arr.splice(arr[i],1);
        }
    }
  console.log(arr); // Expected output [15, -22, 47]
}
</code></pre>