Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "assert/instance-of/docs/types/index.d"

Index

Functions

Functions

Export assignment instanceOf

  • instanceOf(value: any, constructor: Function): boolean
  • Tests whether a value has in its prototype chain a specified constructor as a prototype property.

    throws

    constructor must be callable

    Parameters

    • value: any

      value to test

    • constructor: Function

      constructor to test against

    Returns boolean

    boolean indicating whether a value is an instance of a provided constructor

    Example

    var bool = instanceOf( [], Array );
    // returns true

    Example

    var bool = instanceOf( {}, Object ); // exception
    // returns true

    Example

    var bool = instanceOf( 'beep', String );
    // returns false

    Example

    var bool = instanceOf( null, Object );
    // returns false

    Example

    var bool = instanceOf( 5, Object );
    // returns false