How do we initialize and create new multi dimension array?
Let\'s imagine if I want to initialize a 4x4 multi dimension array and fill it with 0\'s
Ideally,
To get an independent filled array, you could use Array.from and map a new array with mapped values.
var array = Array.from({ length: 4 }, _ => Array.from({ length: 4 }, _ => 4)); array[0][0] = 0; console.log(array);
.as-console-wrapper { max-height: 100% !important; top: 0; }