Browse - Programming Tips - How can I make an array of unsigned 32-bit numbers?
Q. How can I make an array of unsigned 32-bit numbers?
A. As it turns out there is a built-in class for that.
var a = new Uint32Array(256); // Make an empty array of 256 entries
a = 12; // As you'd expect... set element 100 to 12.
console.log('value='+a); // print value of element 100
// Create an 4 element array with values 100, 200, 400, 800
var a = new Uint32Array([100, 200, 400, 800]);
Warning! the array does not grow. So this will NOT work:
var a = new Uint32Array();
a = 44; // Does not work.
You can use the set() member to change the array after its created.