I have been looking for answers here, but I can only find solutions for different programming languages.
Currently, I am dealing with 2 Uint8 typed arrays.
var arr1 = [0,0,0];
var arr2 = [0,1,2,3,4,5,6,7,8,9];
My goal is to replace the contents of arr2 with arr1, starting at the 4th position. This means arr2 should look like this:
arr2 = [0,1,2,0,0,0,6,7,8,9];
If I was not trying to do this in the middle of the array, I could easily use set as shown here:
arr2.set(arr1);
This would give me the following result:
arr2 = [0,0,0,4,5,6,7,8,9];
Although I know that looping through arr2 and copying values individually can achieve the desired outcome, it is incredibly slow compared to using set (and performance is crucial because I am copying an entire array of canvas image data 24 times per second).
Is there a function available that can copy into the middle of an array with the same efficiency as set?