title: JS: ArrayBuffer of Unknown Size
body: <p>I have a big object that I want to store in an ArrayBuffer (let say Uint8Array). Note: I do not know how big the object is.</p>
  
  <p>I already have all the logic about setting the values in the buffer. (It is already working if I use <code>new Uint8Array(100000000);</code> for example.)</p>
  
  <p>The problem is that I don't know if resizing a buffer efficiently is possible. Performance is the main preoccupation here.</p>
  
  <p>I've been thinking starting with let say <code>new Uint8Array(100);</code> and if I need more, I create a new one with double the size <code>new Uint8Array(200);</code> and copy the existing content on the new one (not quite sure how). And so on.</p>
  
  <p>What about just creating a regular array and converting it at the end into a <code>Uint8Array</code>?</p>