💾arr.removeDuplicates()
JS ⟩ value ⟩ object⟩ built-in ⟩ Array ⟩ extension ⟩ arr.removeDuplicates()
Object.defineProperties(Array.prototype, {
// 🔹 .removeDuplicates()
removeDuplicates: {
value: function() {
return [... new Set(this)]; // new array (non-mutating)
},
},
});[ 1, 1, 2, 3, 2, 3, 4 ].randomElement, // (random)
[ 1, 1, 2, 3, 2, 3, 4 ].removeDuplicates(), // [ 1, 2, 3, 4 ]
[1].concat([1,2,3],[2,3,4]), // [ 1, 1, 2, 3, 2, 3, 4 ]
[1].union([1,2,3],[2,3,4]), // [ 1, 2, 3, 4 ]keyword - list all keywords.
contextual keyword - list all contextual keywords.
Last updated
Was this helpful?