C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript TypedArray set() MethodThe JavaScript set() method is used to store values into the given array. Syntax:array.set(array, Index(Offset) ) Parameters:It accepts two parameters which is described below. Array: The array from which to copy values. All the values from the source array are copied into the target array. Index(Offset):At which position to begin writing values from the source array. It is optional and the default value is (0). Return value:A new updated array. Browser Support:
ExampleJavaScript TypedArray set() Method // JavaScript to illustrate set() method // Creating some buffers with sizes in bytes var buffer1 = new ArrayBuffer(8); // Creating some typedArray var A = new Uint8Array(buffer1); // Coping the values into the array // starting at index 2 A.set([ 1, 2, 3, 4],2); // Priniting modified values document.write(A +"<br>"); // expected output:0,0,1,2,3,4,0,0 </script> Output: 0,0,1,2,3,4,0,0
Next TopicJavaScript TypedArray Object
|