2.1.2 • Published 6 years ago

is-prototype-of-x v2.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

is-prototype-of-x

Checks if an object exists in another object's prototype chain.

module.exports(proto, object)boolean

This method checks if an object exists in another object's prototype chain.

Kind: Exported function
Returns: boolean - Does the proto object lay in the prototype chain of object.
Throws:

  • TypeError If proto is undefined or null.
ParamTypeDescription
protoObjectThe proto object to search for.
objectObjectThe object whose prototype chain will be searched.

Example

import isPrototypeOf from 'is-prototype-of-x';

function Foo() {}
function Bar() {}
function Baz() {}

Bar.prototype = Object.create(Foo.prototype);
Baz.prototype = Object.create(Bar.prototype);

const baz = new Baz();

console.log(isPrototypeOf(Baz.prototype, baz)); // true
console.log(isPrototypeOf(Bar.prototype, baz)); // true
console.log(isPrototypeOf(Foo.prototype, baz)); // true
console.log(isPrototypeOf(Object.prototype, baz)); // true
2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.16

6 years ago

2.0.15

6 years ago

2.0.14

6 years ago

2.0.13

6 years ago

2.0.12

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago