Re-filling an array when it is null - Javascript Array

Javascript examples for Array:constructor

Description

Re-filling an array when it is null

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(){/*from  w ww  . j ava 2 s  . co  m*/
var myArray = [];
if (myArray.length == 0) {
    myArray = ["2", "4", "test6", "8", "10", "100", "20", "Bingo!"];
}
console.log(myArray.length)
    }

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

Related Tutorials