The set()
method stores multiple values in the typed array, reading input values from a specified array.
typedarray.set(array[, offset]) typedarray.set(typedarray[, offset])
ArrayBuffer
; the JavaScript engine will intelligently copy the source range of the buffer to the destination range.array
. If you omit this value, 0 is assumed (that is, the source array
will overwrite values in the target array starting at index 0).RangeError
offset
is set such as it would store beyond the end of the typed array.set
methodvar buffer = new ArrayBuffer(8); var uint8 = new Uint8Array(buffer); uint8.set([1, 2, 3], 3); console.log(uint8); // Uint8Array [ 0, 0, 0, 1, 2, 3, 0, 0 ]
Specification | Status | Comment |
---|---|---|
Typed Array Specification | Obsolete | Superseded by ECMAScript 6. |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'TypedArray.prototype.set' in that specification. | Standard | Initial definition in an ECMA standard. |
ECMAScript Latest Draft (ECMA-262) The definition of 'TypedArray.prototype.set' in that specification. | Draft |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 7 | 14 | 4 | 10 | 11.6 | 5.1 |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 4 | Yes | Yes | 4 | 11.6 | 4.2 | Yes |
Server | |
---|---|
Node.js | |
Basic support | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set