var array1 = [1, 2, 3, 4, 5]; var array2 = [0, 7, 1, 2, 3]; var diff = array2.slice(0, array2.indexOf(array1[0])); alert(diff);