> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/decision/isdefined.md).

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
