1.0.2 • Published 6 years ago

memberof v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

memberof

Determines whether an object belongs to a specific subclass.

why memberof

We have typeof and instanceof but these are not precise enough.

So we need memberof.

get start

npm install memberof --save

usage

import memberof from 'memberof'

class MyArray extends Array{
    constructor(){
        super()
    }
}

let arr = new MyArray()

console.log(memberof(arr,MyArray) , arr instanceof MyArray)
// true true

console.log(memberof(arr,Array) , arr instanceof Array);
// false true