Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation  Back up to About Overview 
  
[+] Expand All
[-] Collapse All

Local and Global Variable Declarations

Variables declared using the var keyword are local variables, which persist only for the lifetime of the scope in which they are declared. Top-level local variables in your script are deleted when the script returns. However, variables declared without the var keyword become properties of the global object. Global variables and their data persist between calls to your script.

Note: To avoid unintended consequences, such as memory leaks or security breaches, use local variables by declaring them using the var keyword:

var count = 0; //Local variable declaration

filter = new AttributeFilter(); //Persistent global property

Modified: 2017-09-27