Remove null values from nested arrays - Javascript Array Operation

Javascript examples for Array Operation:Array Nest

Description

Remove null values from nested arrays

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*  w ww. j  a  v a  2s.  co m*/
var arraylist = [0, 1, null, 5];
var i = arraylist.length;
var j =0;
var newlist = [];
while(j < i){
    if(arraylist[j] != null){
       newlist.push(arraylist[j]);
    }
    j++;
}
console.log(newlist);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials