Create array with n elements In react we may need to create list of items usually we do it by mapping over an array if we do not have such an array, we need to make it dynamically const getNumericalArray = (qty = 10) => [...Array(qty).keys()] const arr1 = getNumericalArray() // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] const arr1 = getNumericalArray(5) // [0, 1, 2, 3, 4]