Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36
Chrome 96
Mac OS X 10.15.7
Desktop
3 years ago
Test name Executions per second
Array.prototype.slice() 10496613.0 Ops/sec
spread operator 9644930.0 Ops/sec
Array.prototype.slice(0) 11197079.0 Ops/sec
Script Preparation code:
x
 
var baseArray = []
for (var i = 0; i < 50; i++) {
  baseArray.push((Math.floor(Math.random() * Math.floor(1000000))).toString(16)) 
}
Tests:
  • Array.prototype.slice()

     
    var other = baseArray.slice();
  • spread operator

     
    var other = [ ...baseArray ]
  • Array.prototype.slice(0)

     
    var other = baseArray.slice(0);