I've got array, where every element is an empty array. When trying to execute "array[i].push(el)" instead el is pushed to every single sub array not just array[i].
let columns = new Array(data[0].length).fill([]);
data[0].split('').forEach((el, i) => {
if (i < 5) {
console.log('el: ', el, 'i: ', i);
columns[i].push(el);
}
});
console.log(columns);
in this example only 5 elements of columns should not be empty, instead elements are added to every sub array as if columns[i] was somehow looping through every array inside "columns". Not sure why