Create empty array and check its length - Javascript Array

Javascript examples for Array:length Property

Description

Create empty array and check its length

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   www .  j  a va2 s. c o  m*/
var myArray = [];
if (myArray.length == 0) {
    myArray = ["2", "test4", "6", "8", "10", "100", "20", "Bingo!"];
}
console.log(myArray.length)
    }

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

Related Tutorials