> For the complete documentation index, see [llms.txt](https://wrapper.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://wrapper.angular-package.dev/wrap/methods/instance/hasopening.md).

# hasOpening()

## `Wrap.prototype.hasOpening()`

Checks whether the [primitive value](/wrap/methods/instance/valueof.md) of a specified object has the [`opening`](/wrap/accessors/opening.md) chars or given [`opening`](#opening-string) chars.

{% hint style="info" %}
If given `opening` chars in the constructor are the **empty** `string`, the method returns **`false`**.
{% endhint %}

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

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

{% endcode %}

### Parameters

#### `opening?: string`

Optional opening chars of a [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) type to check if the [primitive value](/wrap/methods/instance/valueof.md) contains them at the **beginning**.

### Returns

The **return value** is a [`boolean`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) indicating whether the [primitive value](/wrap/methods/instance/valueof.md) has the [`opening`](/wrap/accessors/opening.md) chars or given [`opening`](#opening-string) chars.

## Example usage

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

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

// Returns false.
new Wrap(``, `]`, 'quote').hasOpening();
```

### Given `closing` chars

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

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

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

// Returns false.
new Wrap(``, `]`, 'quote').hasOpening('');

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