loading...

re: Learn JavaScript Sets (Simple Yet Powerful Built-In Objects) VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I actually run some benchmarks, and the results were fascinating. Here is the scenario: I've created an array and a set with full of True values an...
 

Not a fair comparison on several dimensions.

  • Set should have only unique values. If you modify populateArray to only store unique elements - that would be an improvement.
  • Set should typically be compared to Object
 

Yes, you are right. But, even if we've stored unique values inside populateArray such as alphabet(a-z) it would still have taken more time than Set. Because it still has to iterate it over with O(n) complexity. What I was trying to show is a mere demonstration of execution of speed

code of conduct - report abuse