1. 2

  2. 2

    I am confused what problem this is solving. You say:

    Currently there isn’t a way to create an array by pre-setting its length and an optional filling value that is both straightforward and safe.


    then you follow with describing safe as being able to create a 2 dimensional array by value instead of reference. but that can already be done a few ways:

    const d1 = 5;
    const d2 = 2;
    Array.from({length: d1}, () => []);
    Array.from(Array(d1), () => Array(d2));
    Array(d1).fill(null).map(() => Array(d2));


    and while they could be more straightforward, they are all one line. So it seems this is just sugar. I am not totally against that, but if youre going to do sugar, why not just do:

    const two_dim = (d1, d2) => {
       return Array.from(Array(d1), () => Array(d2));

    instead of the 60 lines here: