Wrong Way to Make a 2D Array in JavaScript

Yet another pitfall in the land of JavaScript.

Wrong Way to Make a 2D Array in JavaScript

This is a wrong way to make a 2D array in JavaScript.

const n = 4;
const arr2d = Array(n);
lcs.fill(Array(n));
All elements in an array are unintentionally pointing to the same array.