Home › JavaScript Tutorial › JS typed arrays
JS typed arrays
Fixed-type binary data.
Typed arrays such as Uint8Array and Float32Array store numbers compactly and wrap values to their range. They are used for graphics, audio and files.
Example code
<pre id='o'></pre>
<script>
const a=new Uint8Array(3);a[0]=255;a[1]=256;a[2]=-1;
const f=new Float32Array([0.1,0.2]);
o.textContent=[a.join(','),f[0],a.byteLength+' bytes'].join('\n');
</script>