var a = [ 1, 5, 1, 6, 4, 5, 2, 5, 4, 3, 1, 2, 6, 6, 3, 3, 2, 4 ]; var unique = a.filter(function(itm, i, a) { return i == a.indexOf(itm); }); console.log(unique); Run code snippet