1//Array.from() lets you create Arrays from array-like objects
2//(objects with a length property and indexed elements);
3//and also:
4
5//More clearly, Array.from(obj, mapFn, thisArg)
6//has the same result as Array.from(obj).map(mapFn, thisArg),
7//except that it does not create an intermediate array.
8//Basically, it's a declaration that overrides the length property of the method
9//(so that it has to be used with the same name length),
10//setting it with the same value of the given variable.
11//The values are still undefined, it's just a different notation. Take a look:
12
13console.log(Array.from(length, (_,i) => i));
14// It doesn't works with non-iterables
15// In this case we are passing an integer
16
17console.log(Array.from({LENGTH}, (_,i) => i));
18// It doesn't work with a property name different from "length"
19
20console.log(Array.from({length}, (_,i) => i));
21// It works because overrides the .length property of the array
22// The method Array.from() assumes that the property...
23// ...is referring to an iterable (also if not declared)
24
25console.log(Array.from(Array(length), (_,i) => i));
26// This is the demonstration of the above assertion
27// In this case we are using a declared array through...
28// ...an instance of the straight method Array()...
29// ...that accepts an integer as value
30
31//in case any one reads this a got this from er0s in edabit
1Array.of(7); // [7]
2Array.of(1, 2, 3); // [1, 2, 3]
3
4Array(7); // [ , , , , , , ]
5Array(1, 2, 3); // [1, 2, 3]
6
1Array.of(7); // [7]
2Array(7); // array of 7 empty slots
3
4Array.of(1, 2, 3); // [1, 2, 3]
5Array(1, 2, 3); // [1, 2, 3]
6
1String[][] arrays = new String[][] { array1, array2, array3, array4, array5 };
2