# hasText()

## `Wrap.prototype.hasText()`

The method checks whether the [`text`](https://docs.angular-package.dev/wrapper/wrap/accessors/text) of a specified [`Wrap`](https://docs.angular-package.dev/wrapper/wrap) object is defined, which means it's a [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) of at least one char and optionally equal to the given [`text`](#text-string).

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

```typescript
public hasText(text?: string): boolean {
  return (
    this.#text.length >= 1 &&
    (typeof text === 'string' ? this.#text === text : true)
  );
}
```

{% endcode %}

### Parameters

#### `text`?`: string`

Optional text of [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type to check whether it's equal to the [`text`](https://docs.angular-package.dev/wrapper/wrap/accessors/text) of the [`Wrap`](https://docs.angular-package.dev/wrapper/wrap/overview) object.

### Returns

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) indicating whether the [`text`](https://docs.angular-package.dev/wrapper/wrap/accessors/text) is defined and optionally equal to the given [`text`](#text-string).

## Example usage

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

// Returns true.
new Wrap(`[`, `]`, 'quote').hasText();

// Returns false.
new Wrap(`[`, `]`).hasText();

// Returns false.
new Wrap(`[`, `]`, '').hasText();
```

### Given `text`

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

// Returns true.
new Wrap(`[`, `]`, 'quote').hasText('quote');

// Returns false.
new Wrap(`[`, `]`, '').hasText('');
```
