TIL: Set#has run in O(1) compared to Array#includes O(n)
-
-
Replying to @ahmedelgabri
Which probably means that it’s a hashset under the hood
1 reply 0 retweets 0 likes -
Replying to @roman01la
Yeah that's what I was thinking too, but I'm looking for more info about this. To see if my assumption is right or wrong.
1 reply 0 retweets 0 likes -
Replying to @ahmedelgabri
afaik JS Set preserves insertion order, so maybe it’s not exactly O1
2 replies 0 retweets 0 likes
Replying to @roman01la @ahmedelgabri
Why would it not be O(1) because of ordering? Set uses an OrderedHashSet, so lookup is O(1), except in the exceptional case of a hash collision, when it becomes O(n).
3:09 PM - 17 Apr 2018
0 replies
0 retweets
0 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.