As you can see in the above example, but using ++ or --prior to our variable, the operation executes and adds/subtracts 1 prior to returning. https://stackoverflow.com/questions/837648/how-to-increment-a-javascript-variable-using-a-button-press-event/837652#837652. This question should have a title like "how to increment a JavaScript variable based on a web page button press event". JavaScript variables can belong to the local or global scope. So it is possible to have several different variables named x, if and only if they are in different functions (which is the case here). In case you are looking for a continuous numeration try this To decrement a variable value in JavaScript, type the code How to increment a field in MongoDB? We will discuss a few of them with examples − The increment and decrement operators can’t be used with the ‘final’ variables. Returning false caused firefox to hang when I tried it. If you want to try to dynamically make the variable you would need something like ... for(i=0; i