Test name | Executions per second |
---|---|
for..of | 5577367.5 Ops/sec |
for..in | 367476.8 Ops/sec |
for | 297216.8 Ops/sec |
foreach | 5245164.5 Ops/sec |
var arr = [12342, 342, 3423, 432, 432, 423, 43, 3, 1, 321, 323, 1, 31, 31, 31, 231, 31, 31];
const narr = [];
for(const item of arr){
narr.push(item)
}
const narr = [];
for(const item in arr){
narr.push(arr[item])
}
const narr = [];
for(let i=0; i<arr.length; i++){
narr.push(arr[i])
}
const narr = [];
arr.forEach( e => narr.push(e));