> 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/variable-constructor.md).

# Variable() constructor

## `Variable()`

Creates a new instance of [`Variable`](/tag-variable/variable.md) with a specified name and optional value.

{% code title="variable.class.ts" %}

```typescript
constructor(name: Name, value?: Value) {
  super(name, '{', '}');
  isDefined(value) && (this.#value = value);
}
```

{% endcode %}

#### Parameters

<table><thead><tr><th width="173.44477578337126">Name: type</th><th>Description</th></tr></thead><tbody><tr><td><code>name: Name</code></td><td>The variable name in form {name} of a generic type variable <a href="/pages/uX6MIyaORkdFJdrWMOS9#attribute-name"><code>Name</code></a> to create.</td></tr><tr><td><code>value?: Value</code></td><td>An optional variable value of a generic type variable <a href="/pages/uX6MIyaORkdFJdrWMOS9#attribute-name-1"><code>Value</code></a>.</td></tr></tbody></table>

#### Example usage

```typescript
// Example usage.
import { Variable } from '@angular-package/text';


```
