Suppose I need to declare a JavaScript variable based on a counter, how do I do so?
var pageNumber = 1; var \"text\"+pageNumber;
The above
Assuming that the variable is in the global scope, you could do something like this:
var x = 1; var x1 = "test" console.log(window["x" + x]); //prints "test"
However, a better question might be why you want such behaviour.