# IsDefined

Determine whether a given variable reference exists.

For example:

* `isDefined( "luis" )` will test for the existence of an `lmajano` variable in any accessible scope.
* `isDefined( "variables.foo" )` will test for the existence of a `foo` variable in the `variables` scope.
* `isDefined( "brad.age" )` will test for the existence of an `age` key in the `brad` struct, in any accessible scope

## Method Signature

```
IsDefined(variable=[string])
```

### Arguments

| Argument   | Type     | Required | Description                                                                                                                                                                                       | Default |
| ---------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `variable` | `string` | `true`   | <p>The variable reference to test for existence. For security reasons, only dot-notation is supported. Struct/array bracket<br>notation<br>is not supported, nor is function invocation, etc.</p> |         |

## Examples

### Using IsDefined

Checking for the existence of a `form` variable.

```java
<bx:if isDefined( "form.submit" ) >...</bx:if>
```

### Scope Evaluation Order and Unscoped Variables

Beware of scope evaluation order when checking for an unscoped variable name.

[Run Example](https://try.boxlang.io/?code=eJwrLcrRc%2FP3V7BVUCoFMtPy85WsudLyi3JhomA2RLi8KLMkNb%2B0pKC0RENBybNYQR0orq6QkpqWmZeaYq%2BgpKCmkFnsAuFqgLTmKyloKmii6cSiBKRXA6QdyAeSSppKClYKSkogrQC9mS57)

```java
url.FOO = "url.foo";
form.FOO = "form.foo";
writeoutput( "Is 'foo' defined? " & isDefined( "foo" ) );
writeoutput( isDefined( "foo" ) ? " (" & foo & ")" : "" );

```

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.

[Run Example](https://try.boxlang.io/?code=eJyNjrsOgjAYhXee4uQMUBYfQFQS48LgpE6GQQSSJmBNL%2FH1TWGplRjH%2F9z%2Bb1D323AFe6XHlXHNKC1RYwsOk5MFRlazSKb7dNkfq7NPhb0ieWlpO%2BXs01kBVgYfdbRdLx9dWxIppDnMl4ie58ijoR%2FREoTwcyFWCubEGuTXFDeN3i3IHjWmRIz5H%2BEC3CxFXG8CzHSZ)

```java
local[ "form.submit" ] = "local['form.submit']";
form.SUBMIT = "form.submit";
writeoutput( "Is 'form.submit' defined?" & isDefined( "form.submit" ) );
writeoutput( isDefined( "form.submit" ) ? " (" & form.SUBMIT & ")" : "" );
writeoutput( "<br>" );
writeoutput( "Is 'submit' defined? " & isDefined( "submit" ) );
writeoutput( isDefined( "submit" ) ? " (" & submit & ")" : "" );

```

Result: Is 'form.submit' defined? YES (local\['form.submit']) Is 'submit' defined? YES(form.submit)

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxVjbEOgkAQRGv3KzZXYcN9ALEwQmeLPXKDbiJ35m5PTAj%2FLtgYM81M8jLPWs5J%2FI0l1RjEw%2FEkeuc%2BeCcqwXPSTjHCK8lQ%2FLCCzRDiWEYkqOH9mpl21vIpOLAGvoKbN%2FqscEQLJY184HmptlZejue2WbdRJDUVTVEUdR6f%2F4YNfXWPjK%2BgIl7%2FNWbQB8M5Ojo%3D)

```java
// using isDefined with condition statement
if( isDefined( "form.reset" ) ) {
	// Code to be Executed

}
str = {};
str.VALUE = "test";
writeDump( isDefined( "str.value" ) );
 // true

```

## Related

* [ArrayIsEmpty](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/arrayisempty)
* [arrayIsEmpty](https://github.com/ortus-boxlang/boxlang-docs/blob/v1.x/boxlang-language/reference/built-in-functions/decision/arrayIsEmpty.md)
* [Attempt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/attempt)
* [IsArray](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isarray)
* [IsBinary](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isbinary)
* [IsBoolean](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isboolean)
* [IsClosure](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isclosure)
* [IsCustomFunction](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/iscustomfunction)
* [IsDate](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isdate)
* [IsDateObject](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isdateobject)
* [IsDebugMode](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isdebugmode)
* [IsEmpty](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isempty)
* [IsFileObject](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isfileobject)
* [IsIPv6](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isipv6)
* [IsJSON](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isjson)
* [IsLeapYear](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isleapyear)
* [IsLocalHost](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/islocalhost)
* [IsNull](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isnull)
* [IsNumeric](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isnumeric)
* [IsNumericDate](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isnumericdate)
* [IsObject](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isobject)
* [IsQuery](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isquery)
* [IsSimpleValue](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/issimplevalue)
* [IsStruct](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isstruct)
* [IsValid](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isvalid)
* [IsXML](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isxml)
* [IsXmlAttribute](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isxmlattribute)
* [IsXMLDoc](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isxmldoc)
* [IsXMLElem](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isxmlelem)
* [IsXMLNode](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isxmlnode)
* [IsXMLRoot](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isxmlroot)
* [LSIsNumeric](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/lsisnumeric)
* [structIsEmpty](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/structisempty)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isdefined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
