A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/DataView below:

DataView ยท WebPlatform Docs

DataView Summary

You can use a DataView object to read and write the different kinds of binary data to any location in the ArrayBuffer.

Syntax
dataView = new DataView( DataView( buffer , byteOffset , byteLength ));
dataView
Required. The variable name to which the DataView object is assigned.
buffer
The ArrayBuffer that the DataView represents.
byteOffset
Optional. Specifies the offset in bytes from the start of the buffer at which the DataView should begin.
byteLength
Optional. Specifies the length (in bytes) of the section of the buffer that the DataView should represent.
Examples

The following example shows how to use a DataView object to process the binary data acquired from an XmlHttpRequest:

var req = new XMLHttpRequest();
     req.open('GET', "http://www.example.com");
     req.responseType = "arraybuffer";
     req.send();

     req.onreadystatechange = function () {
         if (req.readyState === 4) {
             var buffer = req.response;
             var dataView = new DataView(buffer);
             var ints = new Int32Array(dataView.byteLength / 4);
             for (var i = 0; i < ints.length; i++) {
                 ints[i] = dataview.getInt32(i * 4);
             }
         alert(ints[10]);
         }
     }
Remarks

If both byteOffset and byteLength are omitted, the DataView spans the entire ArrayBuffer range. If the byteLength is omitted, the DataView extends from the given byteOffset until the end of the ArrayBuffer. If the given byteOffset and byteLength references an area beyond the end of the ArrayBuffer, an exception is raised.

Properties

The following table lists the properties of the DataView object.

Property Description buffer Property Read-only. Gets the ArrayBuffer that is referenced by this view. byteLength Property Read-only. The length of this view from the start of its ArrayBuffer, in bytes, as fixed at construction time. byteOffset Property Read-only. The offset of this view from the start of its ArrayBuffer, in bytes, as fixed at construction time. Methods

The following table lists the methods of the DataView object.

Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4