<script> function subArr(a, b) { return a.filter(function(i) { return b.indexOf(i) == -1 }) } console.log(subArr([1,2,3,4],[3,4,5])); </script>