pop vs shift on a array
JavaScript performance comparison
Info
If you can choose between a .pop() or .shift() on a Array, what would be a wise decision?
As my http://jsperf.com/adding-items-array/6 test shows the unshift is awful for performance. The same counts for .shift(), awful performance.
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
.pop() |
|
pending… |
.shift() |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by V1
- Revision 3: published by Sander Aarts
- Revision 5: published by Bruno Garcia
- Revision 6: published by Sander Aarts
- Revision 11: published
- Revision 12: published
- Revision 13: published
0 comments