Test name | Executions per second |
---|---|
for i of | 38362428.0 Ops/sec |
for i in | 2054274.6 Ops/sec |
for i length first | 46811652.0 Ops/sec |
for i length every | 47680224.0 Ops/sec |
while crazy | 40141140.0 Ops/sec |
while boring | 39310488.0 Ops/sec |
slice | 200015872.0 Ops/sec |
let c = 0
const testArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
const newArray = []
for (const i of testArray) {
newArray[c++] = i
}
const testArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
const newArray = []
for (const i in testArray) {
newArray[i] = testArray[i]
}
const testArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
const length = testArray.length
const newArray = []
for (let i = 0; i < length; i++) {
newArray[i] = testArray[i]
}
const testArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
const newArray = []
for (let i = 0; i < testArray.length; i++) {
newArray[i] = testArray[i]
}
const testArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
let i = testArray.length
const newArray = []
while (~--i) {
newArray[i] = testArray[i]
}
const testArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
let i = -1
const newArray = []
while (i++ < testArray.length) {
newArray[i] = testArray[i]
}
const testArray = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ]
const newArray = testArray.slice()