I am initializing my 2D array using the below snippet:
let arr = new Array(m).fill().map(() => new Array(n).fill(-1));
There are some other ways too to initialize it what I need help is in language like C++ there is a simpler way to initialize it using memset. How is time complexity and space complexity affected compared to C++ or Java when using this snippet?