function getIntersection(c, d) { var a = {}; c.map(function (b) { a[b] = !0 }); return a = d.filter(function (b) { return a[b] }) }; alert( getIntersection([-1,3,-4,5,2,6],[-1,0,8,1,2,9,3,-4,5,7]) )