Learn Different ways to create JavaScript Arrays. Image by Clem Onojeghuo 1 . Using assignment operator var array = []; var array2 = [1,2,3,4,5]; 2. Using new operator new Array(length) ; Creates an array with length set to the number. length > 0 otherwise it will throw error var arr = new Array(2); arr; [empty Ă— 2] arr.length; …
Continue reading “Six ways to create an Array in JavaScript.”