slice with array and string
Date tested:
2 years ago
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36
Test name
Executions per second
with array
2336975.0 Ops/sec
with string
2961981.0 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
var s3 = "12"; var s4 = "123"; var s1 = ['1', '2']; var s2 = ['1', '2', '3'];
Tests:
with array
let n1 = s1.slice(-1)[0]; let n2 = s2.slice(-1)[0];
with string
let n3 = s3.slice(-1)[0]; let n4 = s4.slice(-1)[0];
Open this result on MeasureThat.net