Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adding Time complexity documentation for Javascript built-in Object types (espacially array)

4 views
Skip to first unread message

Michael Tresseras

unread,
Jan 12, 2017, 11:02:49 AM1/12/17
to mozilla...@lists.mozilla.org
Hi there,

I was studying algorithms and their time complexities in general and realized I didn't quite know what was the time complexity of some native methods in Javascript.

Does Array.prototype.push have a O(n) or O(1) time complexity ?

I thought "surely you'll find the answer on MDN". I assumed I'll find that answer like I do on the Redis Documentation :

https://redis.io/commands/lpush

So I'm throwing the idea in this thread. Do we want to add that kind of information ? If not, then why can't I find it ?

Thanks guys,

Xue Fuqiao

unread,
Jan 13, 2017, 5:15:45 AM1/13/17
to Michael Tresseras, mozilla...@lists.mozilla.org
Hi Michael,

I think one of the reasons is because different JavaScript engines do
not always implement a method in the same algorithm, and the
implementations may change. It is time-consuming to keep track of the
implementation details of all the engines.
> _______________________________________________
> dev-mdc mailing list
> dev...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-mdc
> MDN contributor guide: http://bit.ly/ContributorGuide
0 new messages