Test name | Executions per second |
---|---|
slice | 30059190.0 Ops/sec |
for loop | 13028219.0 Ops/sec |
forEach | 34328528.0 Ops/sec |
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
const copy = data.slice(3, 8)
const copy2 = data.slice(0, 3)
const copy = [];
const copy2 = [];
for(let i = 0; i < data.length; i++) {
if (i >=3 ) {
copy.push(data[i]);
} else {
copy2.push(data[i]);
};
};
const copy = [];
const copy2 = [];
data.forEach((el, i) => {
if (i >=3 ) {
copy.push(el);
} else {
copy2.push(el);
};
});