jsperf.com/unique-arrays-1
Objects won't work with non-string keys, as well as nasty strings (e.g. __proto__).
__proto__
Correct, these funcs work with the primitives (string and number).
Ref types (comparing objects and arrays) require custom logic, even if working with Set and Map.
eg...
const aDups = [{ id: 1 }, { id: 1 }, { id: 1 }, { id: 1}]; const setDups = new Set(aDups) console.log(setDups) // output: // Set(4) { { id: 1 }, { id: 1 }, { id: 1 }, { id: 1 } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
jsperf.com/unique-arrays-1
Objects won't work with non-string keys, as well as nasty strings (e.g.
__proto__
).Correct, these funcs work with the primitives (string and number).
Ref types (comparing objects and arrays) require custom logic, even if working with Set and Map.
eg...