JavaScript · Middle · Question 69 of 75

Why convert a large list of allowed IDs to a Set before many lookups?

Explanation

For one lookup it doesn't matter; for thousands inside a loop, O(n) per check turns into O(n²) overall.

Further reading

Problem with a question

JavaScript · Middle · question 69

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz