Jump to content

JavaScript Variables Period of Validation


Guest OrientalSieg

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...