Algorithms and Data Structures · Junior · Question 6 of 75

What is the complexity of reading arr[i] from a JavaScript array?

Explanation

Access by index is constant time: the engine computes where the element is instead of walking through the array. That's the main advantage of arrays over linked lists.

Further reading

Problem with a question

Algorithms and Data Structures · Junior · question 6

Test yourself

Take the Algorithms and Data Structures · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz