Instead of
if (arr.length > 0) {
arr.shift();
test(arr, el);
}
Write
if (arr.length > 0) {
test(arr.slice(1), el);
}
arrays are passed as references, so when you shift element it's shifted from array reference (it's one object).
when calling array.slice it duplicates array sliced in chunks you want, so array is remaining unchanged.
or change
test(config, el);
to
test(config.slice(0), el);
in someFunc. test Fn will get duplicated array and will shift elements from one reference for each element.