Test name | Executions per second |
---|---|
Array from | 49608240.0 Ops/sec |
Array loop | 52680016.0 Ops/sec |
Array(length).fill | 52236356.0 Ops/sec |
const length = 100000
function arrayFrom() {
const array = Array.from({length: length}, x => x = true)
}
function arrayLoop() {
const array = [];
for (let i = 0; i < length; i++) array.push(true);
}
function arrayFill() {
const array = Array(length).fill(true);
}