Which fix removes the bug?
const copy = rows; copy.length = 0; console.log(rows.length);
- Copy it first with
const copy = [...rows] - Copy it first with
const copy = {...rows} - Change
copy.length = 0tocopy = [] - Freeze
rowsbefore making the copy
Assignment shares the same array, so clearing the copy clears the original too.
Play Problem Solving ▸