Lawrence Douglas Lawrence Douglas - 8 months ago 27
Node.js Question

Is it possible to create an unsafe array buffer in the browser?


, the
implements a
, which is also available in the browser.

There is a method in
to create an unsafe buffer, where the bytes are not pre-initialized to 0. This is much faster to allocate since you don't have to zero out all the entries, and as long as you later fill everything, it is safe.

Is there anything like this in the client-side browser Javascript? For speed reasons when creating a large amount of arrays which I immediately fill with values, I'm looking for a way to unsafely allocate these buffers.


No, this is not possible. According to the specification, all typed arrays are initialized to 0s.