How to initialize a boolean array in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To initialize a Boolean array in JavaScript, try to run the following code −

Example

Live Demo

<html>
   <head>
      <title>JavaScript Boolean</title>
   </head>
 
   <body>
      <script>
         var myArr = [];
         var value = 2;
         for(var i = 0; i < value; i++) {
            myArr.push(false);
         }
         alert(myArr);
      </script>
   </body>
</html>
raja
Published on 08-Feb-2018 07:48:37
Advertisements