2.1.2 • Published 5 years ago

is-prototype-of-x v2.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 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

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.16

5 years ago

2.0.15

5 years ago

2.0.14

5 years ago

2.0.13

5 years ago

2.0.12

5 years ago

2.0.11

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago