ArrayBufferView

  • Revision slug: JavaScript_typed_arrays/ArrayBufferView
  • Revision title: ArrayBufferView
  • Revision id: 54682
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment add link to DataView; 1 words added

Revision Content

{{ gecko_minversion_header("2") }}{{ draft() }}

The ArrayBufferView type describes a particular view on the contents of an ArrayBuffer's data.

Of note is that you may create multiple views into the same buffer, each looking at the buffer's contents starting at a particular offset. This makes it possible to set up views of different data types to read the contents of a buffer based on the types of data at specific offsets into the buffer.

Note: Typically, you'll instantiate one of the subclasses of this object instead of this base class. Those provide access to the data formatted using specific data types.

 Attributes

Attribute Type Description
buffer ArrayBuffer The buffer this view references. Read only.
byteLength
unsigned long
The length, in bytes, of the view. Read only.
byteOffset
unsigned long
The offset, in bytes, to the first byte of the view within the ArrayBuffer.

Typed array subclasses

The following subclasses provide buffer views allowing access to the data in specific data types:

Type Size Description Equivalent C type
Int8Array 1 8-bit twos complement signed integer signed char
Uint8Array
1 8-bit unsigned integer unsigned char
Int16Array
2 16-bit twos complement signed integer short
Uint16Array
2 16-bit unsigned integer unsigned short
Int32Array
4 32-bit twos complement signed integer int
Uint32Array
4 32-bit unsigned integer unsigned int
Float32Array
4 32-bit IEEE floating point number float
Float64Array
8 64-bit IEEE floating point number double

See also

Revision Source

<p>{{ gecko_minversion_header("2") }}{{ draft() }}</p>
<p>The <code>ArrayBufferView</code> type describes a particular view on the contents of an <a href="/en/JavaScript_typed_arrays/ArrayBuffer" title="en/JavaScript typed arrays/ArrayBuffer"><code>ArrayBuffer</code></a>'s data.</p>
<p>Of note is that you may create multiple views into the same buffer, each looking at the buffer's contents starting at a particular offset. This makes it possible to set up views of different data types to read the contents of a buffer based on the types of data at specific offsets into the buffer.</p>
<div class="note"><strong>Note:</strong> Typically, you'll instantiate one of the <a href="/en/JavaScript_typed_arrays/ArrayBufferView#Typed_array_subclasses" title="en/JavaScript typed arrays/ArrayBufferView#Typed array subclasses">subclasses</a> of this object instead of this base class. Those provide access to the data formatted using specific data types.</div>
<h2> Attributes</h2>
<table class="standard-table" style="width: auto;"> <tbody> <tr> <td class="header">Attribute</td> <td class="header">Type</td> <td class="header">Description</td> </tr> <tr> <td><code>buffer</code></td> <td><a href="/en/JavaScript_typed_arrays/ArrayBuffer" title="en/JavaScript typed arrays/ArrayBuffer"><code>ArrayBuffer</code></a></td> <td>The buffer this view references. <strong>Read only.</strong></td> </tr> <tr> <td><code>byteLength<br> </code></td> <td><code>unsigned long<br> </code></td> <td>The length, in bytes, of the view. <strong>Read only.</strong></td> </tr> <tr> <td><code>byteOffset<br> </code></td> <td><code>unsigned long<br> </code></td> <td>The offset, in bytes, to the first byte of the view within the <a href="/en/JavaScript_typed_arrays/ArrayBuffer" title="en/JavaScript typed arrays/ArrayBuffer"><code>ArrayBuffer</code></a>.</td> </tr> </tbody>
</table>
<h2>Typed array subclasses</h2>
<p>The following subclasses provide buffer views allowing access to the data in specific data types:</p>
<table class="standard-table"> <tbody> <tr> <td class="header">Type</td> <td class="header">Size</td> <td class="header">Description</td> <td class="header">Equivalent C type</td> </tr> <tr> <td><a href="/en/JavaScript_typed_arrays/Int8Array" title="en/JavaScript typed arrays/Int8Array"><code>Int8Array</code></a></td> <td>1</td> <td>8-bit twos complement signed integer</td> <td><code>signed char</code></td> </tr> <tr> <td><code><a href="/en/JavaScript_typed_arrays/Uint8Array" title="en/JavaScript typed arrays/Uint8Array">Uint8Array</a><br> </code></td> <td>1</td> <td>8-bit unsigned integer</td> <td><code>unsigned char<br> </code></td> </tr> <tr> <td><code><a href="/en/JavaScript_typed_arrays/Int16Array" title="en/JavaScript typed arrays/Int16Array">Int16Array</a><br> </code></td> <td>2</td> <td>16-bit twos complement signed integer</td> <td><code>short<br> </code></td> </tr> <tr> <td><code><a href="/en/JavaScript_typed_arrays/Uint16Array" title="en/JavaScript typed arrays/Uint16Array">Uint16Array</a><br> </code></td> <td>2</td> <td>16-bit unsigned integer</td> <td><code>unsigned short<br> </code></td> </tr> <tr> <td><code><a href="/en/JavaScript_typed_arrays/Int32Array" title="en/JavaScript typed arrays/Int32Array">Int32Array</a><br> </code></td> <td>4</td> <td>32-bit twos complement signed integer</td> <td><code>int<br> </code></td> </tr> <tr> <td><code><a href="/en/JavaScript_typed_arrays/Uint32Array" title="en/JavaScript typed arrays/Uint32Array">Uint32Array</a><br> </code></td> <td>4</td> <td>32-bit unsigned integer</td> <td><code>unsigned int<br> </code></td> </tr> <tr> <td><code><a href="/en/JavaScript_typed_arrays/Float32Array" title="en/JavaScript typed arrays/Float32Array">Float32Array</a><br> </code></td> <td>4</td> <td>32-bit IEEE floating point number</td> <td><code>float<br> </code></td> </tr> <tr> <td><code><a href="/en/JavaScript_typed_arrays/Float64Array" title="en/JavaScript typed arrays/Float64Array">Float64Array</a><br> </code></td> <td>8</td> <td>64-bit IEEE floating point number</td> <td><code>double<br> </code></td> </tr> </tbody>
</table><h2>See also</h2>
<ul> <li><a href="/en/JavaScript_typed_arrays/DataView" title="en/JavaScript typed arrays/DataView"><code>DataView</code></a></li> <li><a class=" link-https" href="https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html" title="https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html">Typed Array Specification</a></li> <li><a href="/en/JavaScript_typed_arrays" title="en/JavaScript typed arrays">JavaScript typed arrays</a></li>
</ul>
Revert to this revision