Is there any resource to know the time complexity of natively defined array and string methods in JavaScript? I have to do guess work while I am using them to solve algorithm, but I want to be sure about what is the time complexity of those functions?
Asked
Active
Viewed 1,785 times
6
-
3Note that there isn't a single implementation, so there may be no single, simple answer. – Scott Sauyet Jan 29 '19 at 21:42
-
1The array methods have linear complexity - they just iterate the array. There is nothing specified about string method complexity, as those very much depend on the internal implementation of string values and the applied optimisations. – Bergi Jan 29 '19 at 21:43
1 Answers
2
This question has been answered previously:
Time Complexity for Javascript Methods in V8
In short, it's not specified and the time complexity for common JS methods can differ between browsers.
Worse yet, some methods might not even exist or will behave differently between different browsers and browser versions!

kyle
- 691
- 1
- 7
- 17