desperado,
вариант
var array1 = [1, 2, 3, 4, 5],
array2 = [0, 7, 1, 2, 3];
function foo(arr1, arr2) {
var diff = [];
for (var i = 0; i < arr2.length; i++) {
if (arr1[i] != arr2[i]) {
diff.push(arr2.shift());
i = 0
}
}
return diff
}
alert(foo(array1, array2))