A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the requested number of bytes could not be allocated an exception is raised.
Syntaxuint8Array = new Uint8Array( length );
uintArray = new Uint8Array( array );
uintArray = new Uint8Array( buffer , byteOffset , length );
The following example shows how to use a Uint8Array 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 Uint8Array(buffer.byteLength);
for (var i = 0; i < ints.length; i++) {
ints[i] = dataview.getUint8(i);
}
alert(ints[10]);
}
}
Constants
The following table lists the constants of the Uint8Array object.
PropertiesThe following table lists the constants of the Uint8Array object.
Property Description buffer Property Read-only. Gets the ArrayBuffer that is referenced by this array. byteLength Property Read-only. The length of this array from the start of its ArrayBuffer, in bytes, as fixed at construction time. byteOffset Property Read-only. The offset of this array from the start of its ArrayBuffer, in bytes, as fixed at construction time. length Property The length of the array. MethodsThe following table lists the methods of the Uint8Array object.
AttributionsMicrosoft Developer Network: Article
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