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

4 lines
126 B
JavaScript
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
Array.prototype.unique = function() {
return this.sort().reduce( (a,e) => e === a[a.length-1] ? a : (a.push(e), a), [] )
}