Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
pop() vs shift() (and use the value!)
(version: 0)
Comparing performance of:
pop vs shift
Created:
5 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = []; for(var i = 0; i < 10000; i++){array.push(Math.random());}
Tests:
pop
let sum = 0; while (array.length) { sum += array.pop(); } console.log(sum);
shift
let sum = 0; while (array.length) { sum += array.shift(); } console.log(sum);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
pop
shift
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Already sorted versus random
Array.Sort vs Math.Min-Max
getRandomNumberInRange vs getRandomValueInRange 5000
Set.has v.s Array.includes
yoooooo
Comments
Confirm delete:
Do you really want to delete benchmark?