Check out Firefox Developer Edition, the first browser built for developers like you. http://mzl.la/112VrtT

mozilla
Your Search Results

    Int8Array

    Summary

    The Int8Array typed array represents an array of twos-complement 8-bit signed integers. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).

    Syntax

    Int8Array(length);
    Int8Array(typedArray);
    Int8Array(object);
    Int8Array(buffer [, byteOffset [, length]]);

    For more information about the constructor syntax and the parameters, see TypedArray.

    Properties

    Int8Array.BYTES_PER_ELEMENT
    Returns a number value of the element size. 1 in the case of an Int8Array.
    Int8Array.length
    Length property whose value is 3.
    Int8Array.name
    Returns the string value of the constructor name. In the case of the Int8Array type: "Int8Array".
    Int8Array.prototype
    Prototype for the TypedArray objects.

    Methods

    Int8Array.from()
    See Array.from(). Not implemented, see bug 896608.
    Int8Array.of()
    See Array.of(). Not implemented, see bug 896608.

    Int8Array prototype

    All Int8Array objects inherit from %TypedArray%.prototype.

    Properties

    Int8Array.prototype.constructor
    Returns the function that created an instance's prototype. This is the Int8Array constructor by default.
    Int8Array.prototype.buffer Read only
    Returns the ArrayBuffer referenced by the Int8Array Fixed at construction time and thus read only.
    Int8Array.prototype.byteLength Read only
    Returns the length (in bytes) of the Int8Array from the start of its ArrayBuffer. Fixed at construction time and thus read only.
    Int8Array.prototype.byteOffset Read only
    Returns the offset (in bytes) of the Int8Array from the start of its ArrayBuffer. Fixed at construction time and thus read only.
    Int8Array.prototype.length Read only
    Returns the number of elements hold in the Int8Array. Fixed at construction time and thus read only.

    Methods

    Int8Array.prototype.copyWithin()
    See Array.prototype.copyWithin().
    Int8Array.prototype.entries()
    Returns a new Array Iterator object that contains the key/value pairs for each index in the array.
    Int8Array.prototype.keys()
    Returns a new Array Iterator that contains the keys for each index in the array.
    Int8Array.prototype.move() Unimplemented
    Former non-standard version of Int8Array.prototype.copyWithin().
    Int8Array.prototype.set()
    Stores multiple values in the Int8Array, reading input values from a specified array.
    Int8Array.prototype.subarray()
    Returns a new Int8Array from the given start and end element index.
    Int8Array.prototype.values()
    Returns a new Array Iterator object that contains the values for each index in the array.
    Int8Array.prototype[@@iterator]()
    Returns a new Array Iterator object that contains the values for each index in the array.

    Examples

    // From a length
    var int8 = new Int8Array(2);
    int8[0] = 42;
    console.log(int8[0]); // 42
    console.log(int8.length); // 2
    console.log(int8.BYTES_PER_ELEMENT); // 1
    
    // From an array
    var arr = new Int8Array([21,31]);
    console.log(arr[1]); // 31
    
    // From another TypedArray
    var x = new Int8Array([21, 31]);
    var y = new Int8Array(x);
    console.log(y[0]); // 21
    
    // From an ArrayBuffer
    var buffer = new ArrayBuffer(8);
    var z = new Int8Array(buffer, 1, 4);
    

    Specifications

    Specification Status Comment
    Typed Array Specification Obsolete Superseded by ECMAScript 6.
    ECMAScript 6 (ECMA-262)
    The definition of 'TypedArray constructors' in that specification.
    Draft Initial definition in an ECMA standard.

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 7.0 4.0 (2) 10 11.6 5.1
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support 4.0 (Yes) 4.0 (2) 10 11.6 4.2

    See also

    Document Tags and Contributors

    Last updated by: arai,