# @stamp/instanceof

*Enables* `obj instanceof MyStamp` *in ES6 environments*

```javascript
const InstanceOf = require('@stamp/instanceof');
// or
import InstanceOf from '@stamp/instanceof';
```

It uses the [well known Symbol hasInstance](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance) to test instance.

## Example

Create a stamp:

```javascript
let MyStamp = compose({
  properties: { ... },
  initializers: [function () { ... }]
});
```

The following doesn't work:

```javascript
const obj = MyStamp();
obj instanceof MyStamp === false;
```

Compose the `InstanceOf` to your stamp:

```javascript
MyStamp = MyStamp.compose(InstanceOf);
```

Now it works:

```javascript
const myObject = MyStamp();
obj instanceof MyStamp === true;
```

## Notes

* We do not recommend to use `instanceof` in JavaScript in general.


---

# 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://stampit.js.org/ecosystem/stamp-instanceof.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.
