bohdantheone,
Вариант...
function duplicat(b, c) {
for (var d = [], e = {}, f = {}, a = 0; a < b.length; a++) e[b[a]] = !0;
for (a = 0; a < c.length; a++) f[c[a]] = !0;
for (var g in e) f[g] && d.push(g);
return d
};
alert(duplicat([1,7,2,8,5,12,45,67],[3,4,5,1,2]))