Both put the value 10 in a variable named x . If x does not already exist, it is created on the spot. The scope of a variable is local to the function in which it is created. For example, if a custom function creates a variable y , that variable exists only while the function is being executed. When the function completes its task, the variable y ceases to exist.
All variables are local to the current page.
To extend a variable's scope to other pages, you need to copy the variable to a document cookie. Statement The while statement defines a loop that is executed until some condition proves false. It is usually used when no incrementing counter is needed. Description A while loop is similar to a for loop except that there is no automatically incremented counter in the loop. The condition statement is evaluated once at the start of the loop, then each time execution passes through the loop.