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:
9 months ago
by:
Registered User
Go 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:
9 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
.length--
16K/s
.pop()
14K/s
.slice(0,-1)
4K/s
View exact numbers
Test name
Executions per second
✓
.length--
15,815 Ops/sec
.pop()
14,497 Ops/sec
.slice(0,-1)
3,574 Ops/sec
Related benchmarks
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?