数组操作-数组元素访问

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Test #1
const array = Array(20)
for (let i = 0; i < array.length; i++) {
  array[i] = i;
}
let res = 0
for (let i = 0; i < array.length; i++) {
  const element = array[i]
  res += element
}
ready
Test #2
const array = Array(20)
const length = array.length
for (let i = 0; i < length; i++) {
  array[i] = i;
}
let res = 0
for (let i = 0; i < length; i++) {
  const element = array[i]
  res += element
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.