1

I am wondering how Set in ES6 is implemented under the hood. For example, if we do new Set(arr) and there are duplicates in arr, how Set removes them?

bohkoval
  • 365
  • 1
  • 9

1 Answers1

0

It is done by checking the value equality ( === ) for every value in the set. If a duplicate value is found it isn't stored in the set.

For more info- this

ellipsis
  • 12,049
  • 2
  • 17
  • 33