What are the big O notations of Javascripts Map.prototype.has and Set.prototype.has methods?
According to the documentation for Set:
The following steps are taken:
- Let S be the this value.
- If Type(S) is not Object, throw a TypeError exception.
- If S does not have a [[SetData]] internal slot, throw a TypeError exception.
- Let entries be the List that is the value of Sās [[SetData]] internal slot.
- Repeat for each e that is an element of entries,
- If e is not empty and SameValueZero(e, value) is true, return true.
- Return false.
The description makes Set sound like it is looping through an array, as opposed to retrieving the result in constant time.
The description of Map.prototype.has is almost the same as well. Thus, what is the big O notation of Map.prototype.has and Set.prototype.has?
Is one faster than the other?