Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Delete last element from Array
(version: 2)
Comparing performance of:
.pop() vs .slice(0,-1) vs .length--
Created:
5 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
let arr = []; const N = 0x40000; for(i=0;i<N;i++) arr[i]=Math.random();
Tests:
.pop()
[...arr].pop()
.slice(0,-1)
[...arr].slice(0,-1)
.length--
[...arr].length--
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
.pop()
.slice(0,-1)
.length--
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
.pop()
14497.3 Ops/sec
.slice(0,-1)
3574.5 Ops/sec
.length--
15814.9 Ops/sec
Related benchmarks:
filtrowanie2
Destructure first elem vs pop
Array check key
Last item in array pop vs length - 1
Getting last element of array
Array last index
length assignment during loop
Getting last element of array (index/slice/at/pop)
How to clear an array
Comments
Confirm delete:
Do you really want to delete benchmark?