Subj : Re: Byte Arrays in JavaScript To : Sajid Raza From : Brendan Eich Date : Sun May 23 2004 12:06 am Sajid Raza wrote: > My application reads and writes large quantities of data. I would like > to present my 'users' with an array like data-structure that contains > bytes. The present Array object relies on 32-bit jsvals that may not be > as space-efficient as ideally possible. I could hack together a class > that emulates byte-arrays, but I was wondering whether there's a nice > clean way of doing this. Basically, my concern is that how properties > are resolved may not allow me to stuff more data into each jsval in the > properties vector. Is there a way for me to store 4 bytes in each slot > of an object, and still be able to index each element properly? You shouldn't use slots at all; see JSPROP_SHARED in jsapi.h. Use resolve to lazily reflect byte-valued properties of the class prototype that have the JSPROP_SHARED attribute, and whose getter and setter know how to index into a private byte array data struct per instance. Are these byte arrays typically or always dense? /be .