I am wondering about the structure of my code which includes variables x_1, x_2, x_3, …., x_n
being passed in an array. Here is how it looks:
var x_1 = "something";
var x_2 = "something";
var x_3 = "something";
.
.
.
var x_n = "something";
var parameters = [ x_1, x_2, x_3, …, x_n ];
someFunction.apply(this, parameters);
Is it necessary for each variable in the parameters
array to be declared somewhere else in the code? Or can I simply pass values like this:
var parameters = ["something", "something", "something", …, "something" ];
someFunction.apply(this, parameters);
In essence, can I include the actual variables x_1, x_2, x_3, …, x_n
in the parameters
array or should I only include their respective values?
If there is a better way to achieve this, or if my approach may not work as intended based on the example provided, I would appreciate any suggestions or alternatives.