IsDefined
Determine whether a given variable reference exists.
For example:
isDefined( "luis" )
will test for the existence of anlmajano
variable in any accessible scope.isDefined( "variables.foo" )
will test for the existence of afoo
variable in thevariables
scope.isDefined( "brad.age" )
will test for the existence of anage
key in thebrad
struct, in any accessible scope
Method Signature
Arguments
variable
string
true
The variable reference to test for existence. For security reasons, only dot-notation is supported. Struct/array bracket notation is not supported, nor is function invocation, etc.
Examples
Using IsDefined
Checking for the existence of a form
variable.
Scope Evaluation Order and Unscoped Variables
Beware of scope evaluation order when checking for an unscoped variable name.
Result: Is 'foo' defined? YES (url.foo)
Dot-notation Variable Names
Potentially unexpected behavior when checking for a dot-notation variable containing a scope name.
Result: Is 'form.submit' defined? YES (local['form.submit']) Is 'submit' defined? YES(form.submit)
Additional Examples
Related
Last updated
Was this helpful?