> For the complete documentation index, see [llms.txt](https://text.angular-package.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://text.angular-package.dev/tag-variable/variable.md).

# Variable

The `Variable` is an extension of the [`Tag`](/tag/tag.md) string object and represents an [immutable](https://developer.mozilla.org/en-US/docs/Glossary/Immutable) variable in the form of name between curly brackets e.g. **`{fix}`** with the ability to set its value.

### Instance accessors

| Variable.prototype.                                                                                               | Description                                                                                                                                                                                                                                                                    |
| ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [value](https://text.angular-package.dev/tag-variable/pages/twcBY1hCusIQFq090LaA#variables.prototype.value)       | The [`get`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get) accessor returns the value from a private [`#value`](/tag-variable/variable/instance-properties.md#value) property of a specified [`Variable`](/tag-variable/variable.md) object. |
| [variable](https://text.angular-package.dev/tag-variable/pages/twcBY1hCusIQFq090LaA#variables.prototype.variable) | The [`get`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get) accessor returns the variable in form `{variable name}`, a primitive value of the specified [`Variable`](/tag-variable/variable.md) object.                                       |

### Static methods

| Variable.                                                                                                    | Description                                                                                                         |
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------- |
| [define()](https://text.angular-package.dev/tag-variable/pages/EIokaaHnUz9B6mnfDs2j#variable.define)         | The static method defines the [`Variable`](/tag-variable/variable.md) of a specified name with an optional value.   |
| [isVariable()](https://text.angular-package.dev/tag-variable/pages/EIokaaHnUz9B6mnfDs2j#variable.isvariable) | The static method checks whether the value of any type is an instance of a [`Variable`](/tag-variable/variable.md). |

### Instance methods

| Variable.prototype.                                                                                                              | Description                                                                                                                                                                                      |
| -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [getValue()](https://text.angular-package.dev/tag-variable/pages/S7PTtQn5hYYPTuahE7v7#variable.prototype.getvalue)               | Gets the value of the variable by returning the private [`#value`](/tag-variable/variable/instance-properties.md#value)  property of a specified [`Variable`](/tag-variable/variable.md) object. |
| [replaceVariable()](https://text.angular-package.dev/tag-variable/pages/S7PTtQn5hYYPTuahE7v7#variable.prototype.replacevariable) | Replaces variable in the format `{variable name}` with the value of a specified [`Variable`](/tag-variable/variable.md) object or with a provided `replaceValue`, in a given `text`.             |
| [toArray()](https://text.angular-package.dev/tag-variable/pages/S7PTtQn5hYYPTuahE7v7#variable.prototype.toarray)                 | Returns converted variable to a read-only `array` where the first element is the name, and the second is the value if set, otherwise `undefined`.                                                |
| [toObject()](https://text.angular-package.dev/tag-variable/pages/S7PTtQn5hYYPTuahE7v7#variable.prototype.toobject)               | Returns converted variable to a read-only `object` where the key is the variable name.                                                                                                           |
| [toString()](https://text.angular-package.dev/tag-variable/pages/S7PTtQn5hYYPTuahE7v7#variable.prototype.tostring)               | Returns the variable in form `{name}`, a primitive value of the specified [`Variable`](/tag-variable/variable.md) object.                                                                        |
| [valueOf()](https://text.angular-package.dev/tag-variable/pages/S7PTtQn5hYYPTuahE7v7#variable.prototype.valueof)                 | Returns the variable in form `{name}`, a primitive value of the specified [`Variable`](/tag-variable/variable.md) object.                                                                        |
