The Javascript TypedArray set() method holds values in an array.
Syntax:
array.set(array, Index(Offset))
Parameters:
array: It represents the source array.
Index(Offset): It represents the index position of the source array from where to start. The default value is 0.
Returns:
Modified array.
Example 1:
<!DOCTYPE html> <html> <body> <script type="text/javascript"> var a = new ArrayBuffer(8); var b = new Uint8Array(a); b.set([20,50,50,40,50],1); document.write(b); </script> </body> </html>
Example 2:
<!DOCTYPE html> <html> <body> <script type="text/javascript"> const testBuffer = new ArrayBuffer(8); const testArray = new Uint8Array(testBuffer); testArray.set([13, 22, 43], 2); document.write(testArray); </script> </body> </html>