https://github.com/mmiller42/instance-of-name
Checks the prototypical chain of an object and compares each constructor's name against the value.
https://github.com/mmiller42/instance-of-name
Last synced: 3 months ago
JSON representation
Checks the prototypical chain of an object and compares each constructor's name against the value.
- Host: GitHub
- URL: https://github.com/mmiller42/instance-of-name
- Owner: mmiller42
- License: mit
- Created: 2016-06-20T00:33:30.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-06-25T00:05:09.000Z (almost 9 years ago)
- Last Synced: 2025-03-11T01:09:58.628Z (3 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# instance-of-name
Checks the prototypical chain of an object and compares each constructor's name against the value.## Installation
```shell
npm install instance-of-name
```## API
### `instanceOf(object, className)`
#### Arguments
* object `object` The object to check
* string `className` The name of the constructor function## Usage
```
import instanceOf from 'instance-of-name';class Car {}
class Ford extends Car {}
class Focus extends Ford {}let focus = new Focus();
focus instanceof Focus; // true
focus instanceof Ford; // true
focus instanceof Car; // true
focus instanceof Object; // true
focus instanceof Array; // falseinstanceOf(focus, 'Focus'); // true
instanceOf(focus, 'Ford'); // true
instanceOf(focus, 'Car'); // true
instanceOf(focus, 'Object'); // true
instanceOf(focus, 'Array'); // false
```