let arr=[1,2,3,4]; let arr1=[1,2,3,4,5,6,7,8,"a"]; function array_diff(a, b) { for(let i=0;i<b.length;i++){ for(let j=0;j<a.length;j++){ if(a[j]===b[i]){ a.splice(j,1); j=j-1; } } } return a; } console.log(array_diff(arr1,arr))