Standard built-ins
TypedArray.prototype.set()
Copies values into the target view, converting elements to its numeric type. Throws when the source cannot fit; overlapping typed views are handled.
Formal Syntax & Structure
javascript syntaxjavascript
target.set(source, offset?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| source | TypedArray | ArrayLike | Values to copy. |
| offset | number | Starting element index; defaults to 0. |
Return Value
undefined
Mutates the target view.
Working Example
Example Snippetjavascript
const a=new Uint8Array([1,2,3,4]); a.set(a.subarray(0,3),1); console.log(JSON.stringify([...a]));