RosettaCodeData/Task/Remove-duplicate-elements/JavaScript/remove-duplicate-elements-3.js

4 lines
126 B
JavaScript
Raw Normal View History

2015-11-18 06:14:39 +00:00
Array.prototype.unique = function() {
return this.sort().reduce( (a,e) => e === a[a.length-1] ? a : (a.push(e), a), [] )
}