Export (0) Print
Expand All

set Method (Uint32Array)

Sets a value or an array of values.

uint32Array.set(index, value);
uint32Array.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 Uint32Array(buffer.byteLength / 4);
            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.

Show:
© 2014 Microsoft