Skip to content

Create a zero filled array in JavaScript

Advertisements

To create a zero-filled array, we can use the Uint8Array typed array. Uint8Array created an array of 8 bit unsigned integer. By default the array elements are assigned to 0.

var arr = new Uint8Array(10);
console.log(arr); //[0,0,0,0,0,0,0,0,0,0]
See also  Permuting Two Arrays - Hackerrank Challenge - Java Solution
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.