Advanced: variable resolution & scoping
Jess has two variable-reference forms:
| Reference | Resolution model |
|---|---|
$foo | Live: reads the current binding at evaluation time. |
$$foo | Scoped/final lookup. |
$foo: live
Use $foo when the value should follow the current binding at the point where it
is evaluated.
$$foo: scoped/final
Use $$foo when you want the scoped/final lookup explicitly.
Missing names
Both forms report an unresolved name as a ReferenceError unless the caller is
performing an explicit optional/existence operation.
Declaration and assignment lookup
| Form | Behavior |
|---|---|
$foo: value / $$foo: value | Create or update both bindings. |
$foo?: value | Check the live binding; create/update both if absent. |
$$foo?: value | Check the scoped/final binding; create/update both if absent. |
$foo := value | Update the live/current binding. |
$$foo := value | Update the scoped/final binding. |