Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Chrome 132
Linux
Desktop
one year ago
Test name Executions per second
Push item to an array 45580.6 Ops/sec
Append an item by spread 573.6 Ops/sec
Direct assign an item to an initialized array 109675.5 Ops/sec
items[items.length] 70598.4 Ops/sec
items[items.length] outer length counter 74660.8 Ops/sec
items[items.length] outer length counter + new Array() 109864.1 Ops/sec
Script Preparation code:
Tests:
  • Push item to an array

  • Append an item by spread

  • Direct assign an item to an initialized array

  • items[items.length]

  • items[items.length] outer length counter

  • items[items.length] outer length counter + new Array()

  • Cutting empty tail