Test name | Executions per second |
---|---|
While Loop with declaration | 303659.9 Ops/sec |
While Loop with Array.from | 303098.6 Ops/sec |
While Loop with Push and Array.From | 274984.6 Ops/sec |
While Loop with Push | 283912.2 Ops/sec |
Array.from with map | 218462.0 Ops/sec |
var size = 15;
const array = [];
array.length = size;
let index = array.length;
while (index-- > 0) {
const temp = [];
temp.length = size;
array[index] = temp;
}
const array = [];
array.length = size;
let index = array.length;
const temp = [];
temp.length = size;
while (index-- > 0) array[index] = Array.from(temp);
const array = [];
array.length = size;
let index = array.length;
const temp = [];
temp.length = size;
while (index-- > 0) array.push(Array.from(temp));
const array = [];
array.length = size;
let index = size;
while (index-- > 0) {
const temp = [];
temp.length = size;
array.push(temp);
}
const array = Array.from(Array(size), () => {
const temp = [];
temp.length = size;
return temp;
});