keys() method to get an Array Iterator Object with the array’s keys. It will create a new array with a length property set to the number we passed in Array(). Pass an integer ranging from 0 to 2^(32 - 1) (inclusive) to the Array() constructor.Use the Array() constructor to instantiate the Array class or we can say to create an Array object.If we are using ES6 (ECMAScript6), then we can use this approach to create the array from 1 to 100 in JavaScript: What if we can have some shorter ways of achieving the same results? Let’s explore them below. You may have noticed that using the for loop requires more lines of code and care. The third expression can also be omitted, and we can increment the variable’s value inside the for loop. Remember, if we don’t want to have the second expression, we must write a break inside the for loop otherwise, it would be a never-ending loop and crash the browser. The second expression is optional, and we can omit that. Note that we can initialize multiple variables in the first expression this case would be helpful if we have to create two arrays, one from 1 to 100 and the second from 101 to 200 using one for loop.
In that case, we can initialize the variable’s value before writing the loop. The first expression is optional, and we can omit it.