Thursday, 5 February 2015

How to create a static variable in javascript ?

You can use the .counter property of JavaScript function to achieve this:

function staticVariable(change)
{
if (change == "next") {
    staticVariable.counter++;
}
else if(change=="prev")
{
    staticVariable.counter++;
}
Now you have a static variable as: staticVariable.counter

No comments:

Post a Comment