Skip to content

Latest commit

 

History

History
72 lines (58 loc) · 1.93 KB

File metadata and controls

72 lines (58 loc) · 1.93 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic dev_langs ms.assetid caps.latest.revision author ms.author manager
set Method (Uint16Array) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
JavaScript
TypeScript
DHTML
5bfbc50b-d786-4c0d-918a-ae1241a32626
10
mikejo5000
mikejo
ghogen

set Method (Uint16Array)

Sets a value or an array of values.

Syntax

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

Parameters

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.

Remarks

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.

Example

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

Requirements

[!INCLUDEjsv10]