Variables

Top  Previous  Next

Like regular Javascript, you can create local variables to your script using the var statement:

var x = 3

You can then reference them by name, "x".  These variables will go out of scope and thus disappear when the script completes.  To create a global variable that is accessible between scripts and script executions, use "global.":

global.x = 3

Reference global variables using global. as well: "global.x"

 

Advanced: because all script is run in a sandbox, it is impossible to create a true, system global variable.  You can access them (for example: window.location), you just can't create them.  You can access script global variables from outside the sandbox by accessing the sandbox: $.dc.sandbox.global.x for example.  "global" is simply an empty object declared in $.dc.sandbox and doing global.x = 3 simply adds a member variable to the global object.