JavaScript Typed Arrays

One of the things we use a lot in our audio and canvas demos and libraries, is Typed Arrays.  A typed array looks and feels a lot like a native JavaScript array, but for situations where your data is uniform, and of the same type (cf. buffers of sound or pixels), using a typed array provides a big performance improvement.  They were implemented as part of WebGL, but can be used anywhere.  I used them in the implementation of the Audio Data API, for example.  If you haven't heard of them before, now you have, and can ignore the rest.

If you've been working with Typed Arrays for a while in nightlies or betas (you're running nightlies and betas, right?), you need to know that there was a recent interface change.  The other day Vlad pinged me to let me know that bug 630117 was about to land, and that it might break our code.  Today I had other people telling me that the latest nightly was broken, and this was the cause.  So if you're using slice() on a typed array, read this bug.

Show Comments