Create a Zero-Filled JavaScript Array



To create a zero-filled JavaScript array, use the Unit8Array typed array.

Example

You can try to run the following code:

Live Demo

<html>
   <body>
      <script>
         var arr1 = ["marketing", "technical", "finance", "sales"];
         var arr2 = new Uint8Array(4);
         document.write(arr1);
         document.write("<br>Zero filled array: "+arr2);
      </script>
   </body>
</html

Output

marketing,technical,finance,sales
Zero filled array: 0,0,0,0
Updated on: 2020-01-13T10:28:00+05:30

105 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements