# hasText()

## `Wrap.prototype.hasText()`

The method checks whether the [`text`](https://wrapper.angular-package.dev/wrap/accessors/text) of a specified [`Wrap`](https://wrapper.angular-package.dev/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://wrapper.angular-package.dev/wrap/accessors/text) of the [`Wrap`](https://wrapper.angular-package.dev/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://wrapper.angular-package.dev/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('');
```


---

# 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://wrapper.angular-package.dev/wrap/methods/instance/hastext.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.
