Is there a quickest way to find a sub array in an array ? For exemple with anonymous methods ?
In my case, the master array is a frame of bytes received from a device, the sub-array is the characteristic sequence of the beginning of the waited answer. The device is a Lidar, so the best is the quickest possible processing.
function findSubArray( master, sub, fromPos) {
let pos = null;
if ( ! fromPos) fromPos = 0;
do {
if (master.length < sub.length) break;
if (fromPos > (master.length - sub.length)) break;
for( m=fromPos; m < (master.length - sub.length - fromPos+1); m++) {
let masterPos = m;
for( s=0; s < sub.length; s++) {
if (sub[s] != master[m + s]) {
masterPos = -1;
break;
}
}
if (masterPos != -1) {
pos = masterPos;
break;
}
}
} while( false);
return pos;
}
Best regards.


array[someIndex]===subArray) or is it that if values match(array=[1,2,3,4],subArray=[2,3])?array=[1,2,3,4],exampleSubArray=[2,3]?