Jump to content

JavaScript Variables Period of Validation


Guest OrientalSieg
 Share

Recommended Posts

Guest OrientalSieg

Dear all,How can I keep a varible valid from one run of a javascript function to the next run of the same function?Is it possible to store a variable somewhere and to retrieve it in the next run?Regards

Link to comment
Share on other sites

You can store it in a global variable.For example:

var G; // Declare the global variable outside of the functionsfunction doSomething(incomeValue) {  if(!G) {	G = incomeValue;  } else {	G++  }  alert(G);}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...