Given two sorted arrays check if one is subset of another
There is a O(n) solution to this.  

Finding all possible start index of the subset can be eliminated

while(loc &gt; -1) {
    allIndexes.push(loc);
    loc = a1.indexOf(a2[0], loc + 1);
}


And, there seems to be an edge case where it will attempt to access element out of the array's bounds. I mean, the input like the one below

A1 = [-1, 0, 1, 3, 1, 2], A2 = [1, 2, 3]


The below pseudocode-like is a starting point, there is still optimisations left in this algorithm. 

Given array A, find the presence of sub array B,

matchPointer = 1
for i = 1 to A.length
  if A[i] == B[matchPointer]
    if matchPointer == B.length
      "Subset Found"
    matchPointer = matchPointer + 1
  else
    matchPointer = 1;