Skip to content Skip to sidebar Skip to footer

Time Complexity For Javascript Methods In V8

I know that the Javascript standard does not specify required time complexities for methods like array unshift but is there a reference for time complexities in a specific Javascri

Solution 1:

is there a reference for time complexities in a specific Javascript engine like V8?

No.

The ECMA specification does not specify a bounding complexity, as you already might know, and nor does that engine. Every JavaScript engine is free to implement its own functionality, as long as it is compatible with the Standard.

V8, for example, does not provide Time Complexities for its methods.

You could of course look at the source code, construct the algorithm used under the hood in our mind, understand it, analyse it and then come up with a bound for its Time Complexity.

Solution 2:

Check THis.

Mutator Methods.

  1. push() - 0(1)
  2. pop() - 0(1)
  3. shift() - 0(n)
  4. unshift() - 0(n)
  5. splice() - 0(n)
  6. sort() - 0(n log(n))

Accessor methods

  1. concat() - 0(n)
  2. slice() - 0(n)
  3. indexOf() - 0(n)

Iteration methods

  1. forEach() - 0(n)
  2. map() - 0(n)
  3. filter() - 0(n)
  4. reduce() - 0(n)

Post a Comment for "Time Complexity For Javascript Methods In V8"