Setting an array with integers?

Hello everyone! I've learned a bit about arrays over the last month or so, and think I have a decent understanding of how they function, when you manually set the numbers/strings within an array. But my question is, is it possible to do this for a larger pool of options without having to type them all manually, like instead of listing them in the array as "1,2,3,4,5,6,7,8,9,10," how would one go about designating the pool to simply be "1 through 10."

I can't seem to figure out how to search for similar questions to this, so thanks in advance!
Well since you did not give a specific case, I can just show you the basics.
The following code can be put into a "Script-Call".

JavaScript:
let my_Array = [];
for (i = 1; i < 11; i++){
my_Array.push(i);
}
$gameVariables.setValue(X, my_Array);

#1 We create a temporary variable to initialize our Array.
#2 We create a "for-loop" to iterate "i" from 1 to 10.
#3 In each loop-cycle, we put the current number "i" into the previously created array by using the "push"-method.
#4 After the Loop is done, all numbers from 1 to 10 are present in the array.
#5 You can then put the array into one of your game variables. For that you replace the "X" with any variable ID of your choosing.

Note: I am not an expert on Javascript myself, so I don't know if this is the best way to do it, but it worked for me.
@ScorchedGround Good move, I would just like to move this into a method:

JavaScript:
function createArray(a, b) {
    const array = [];
    for (let i = a; i < b; i++) { array.push(i) }
    return array;
}

// call Array
const myArray = createArray(5, 8);
If you want an array holding the numbers 1 through 10, you can use the spread operator, like this:
JavaScript:
[...Array(10).keys()].map(e => e + 1)

First, Array(10) creates an empty array of size 10.

Then, .keys() gives you an iterator of the array's keys (that's 0 through 9, used to access the items of the array created).

The spread operator ... is only valid inside round brackets (for function call), square brackets (for creating arrays) or curly brackets (for cloning objects), and only works on iterable objects (like strings, arrays or iterators). It's basically the equivalent to doing [ A[0], A[1], A[2], ..., A[9] ] if A was an array of size 10.

Since we've now created an array that contains 0 to 9, but we want 1 to 10, we use .map(e => e + 1). The map(f) function iterates through the entire array, passes each element of that array into function f and creates a new array with the same size, where each element is the result of function f.

Finally, e => e + 1 is an arrow function that takes an argument e (in this case a number from 0 to 9), and returns e + 1 (giving us 1 to 10). It's similar to function(e) { return e + 1 }, but shorter. Arrow functions also behave differently regarding their context, which affects this, but isn't really important in this case, since we don't use this.
Moved to: Learning Javascript
That's a really good explanation (I don't know if I'll ever need it, but it was new material for me). Just for future reference, the correct English terminology is:
round brackets, square brackets or curly brackets
parentheses, brackets, and braces 🙂

Original thread: https://forums.rpgmakerweb.com/threads/setting-an-array-with-integers.139522/