Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

set Method (Int16Array)

Sets a value or an array of values.

int16Array.set(index, value);
int16Array.set(array, offset);

index

The index of the location to set.

value

The value to set.

array

A typed or untyped array of values to set.

offset

The index in the current array at which the values are to be written.

If the input array is a TypedArray, the two arrays may use the same underlying ArrayBuffer. In this situation, setting the values takes place as if all the data is first copied into a temporary buffer that does not overlap either of the arrays, and then the data from the temporary buffer is copied into the current array.

If the offset plus the length of the given array is out of range for the current TypedArray, an exception is raised.

The following example shows how to set the first element of the array.

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 intArr = new Int16Array(buffer.byteLength / 2);
            intArr.set(0, 9);
        }
    }

Supported in the following document modes: Internet Explorer 10 standards and Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information. Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft