14

My question is related to computational complexity of Set / Map, Weak Set / Weak Map polyfills by Babel? Afaik there are no ES5 language features allowing to implement Set / Map directly, and so it might happen that Set / Map might use Array structure under the hood to implement lookup by object reference which would yield to O(N) lookup performance. And so the question is:

What is the computational complexity of Set / Map lookup operations?

Thank you in advance!

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Lu4
  • 14,873
  • 15
  • 79
  • 132
  • 2
    [tag:babel]: *"Python internationalization library with an emphasis on web-based applications. For questions about the JavaScript library, please use [tag:babeljs]."* (=> please read tag descriptions) – Felix Kling Jan 14 '16 at 13:08

1 Answers1

11

Babel uses core-js for its polyfill, from the GitHub repo:

core-js uses native collections in most case, just fixes methods / constructor, if it's required, and in old environment uses fast polyfill (O(1) lookup).

(Emphasis mine)

And if you're interested in the exact lookup, it's in this file. It's not backed by an array.

Matthias
  • 13,607
  • 9
  • 44
  • 60
CodingIntrigue
  • 75,930
  • 30
  • 170
  • 176