I want an array with N zeroes, like
[0,0,0,0...0] I could do a for-loop and push them all, but is there a nicer way?
var x = [] for (var i = 0; i < N; i++) { x.push(0) }; I want an array with N zeroes, like
[0,0,0,0...0] I could do a for-loop and push them all, but is there a nicer way?
var x = [] for (var i = 0; i < N; i++) { x.push(0) }; Use Int8Array:
var x = new Int8Array(100) # x now is filled with 0s and is of size 100 The Int8Array typed array represents an array of twos-complement
8-bit signed integers. The contents are initialized to0.
See also: http://www.ecma-international.org/ecma-262/6.0/#table-49