Compare Revisions

JavaScript typed arrays

Revision 8103:

Revision 8103 by vjeux on

Revision 8104:

Revision 8104 by vjeux on

Title:
JavaScript typed arrays
JavaScript typed arrays
Slug:
JavaScript_typed_arrays
JavaScript_typed_arrays
Tags:
javascript, NeedsBrowserCompatibility, WebGL, js-ctypes, "JavaScript typed arrays", WebSockets
javascript, NeedsBrowserCompatibility, WebGL, js-ctypes, "JavaScript typed arrays", WebSockets
Content:

Revision 8103
Revision 8104
tt118    <p>
119      The same example with DataView
120    </p>
121    <pre>
122var buffer = new ArrayBuffer(24);
123// ... read the data into the buffer ...
124 
125var view = new DataView(buffer);
126 
127var id = view.getUint32(0);
128// There is no easy way to get a string with the DataView, we use
 > Uint8Array
129var username = String.fromCharCode(new Uint8Array(buffer, 4, 16))
 >;
130var amount = view.getFloat32(20);
131</pre>

Back to History