How can I create static variables in Javascript?
In JavaScript variables are static by default. Example:
var x = 0; function draw() { alert(x); // x+=1; } setInterval(draw, 1000);
The value of x is incremented by 1 every 1000 milliseconds It will print 1,2,3 so forth