these are few examples of the Array constructor use.
var arr2 = new Array(50); // returns [50 empty elements]
var arr3 = new Array(1, 2, "three", 4, "five"); // returns [1, 2, 'three', 4, "five"]
var arr4 = new Array([1, 2, 3, 4, 5]); // returns [[1, 2, 3, 4, 5]] ```
if i want to construct an array with only one element say 4. [4] How do i construct using the array constructor? If i use new Array(4) it will construct an array of length 4 with four empty elements [4 empty elements].
var arr = [4]?Array.of(4)was created.Arrayconstructor (except asnew Array(n)to construct an-length array), and I don't think I have ever seen it used, so this is not a big loss. Use a literal when you need to specify a hard-coded array, use variousArray(and other) methods to make arrays dynamically... and don't usevarnow that we haveconstandlet.