• Skip to main content
  • Skip to search
  • Skip to select language
HTML

Structure of content on the web

  • Web APIs

    Interfaces for building web applications

  • Learn
    • CSS

      Learn to style content using CSS

    • Overview

      A customized MDN experience

    • FAQ

      Frequently asked questions about MDN Plus

  • HTTP Observatory

    Scan a website for free

  • JavaScript
  • [Symbol.hasInstance]()
      • Deutsch
      • 日本語
      • 한국어
      • 中文 (简体)

    In this article

    • Syntax
    • Description
    • Examples
    • Specifications
    • Browser compatibility
    • See also
    1. apply()
    2. [Symbol.hasInstance]()
  • Instance properties
    1. displayName Non-standard
    2. arguments Non-standard Deprecated
    3. caller Non-standard Deprecated
  • Inheritance
  • call()
  • displayName Non-standard
  • arguments Non-standard Deprecated
  • caller Non-standard Deprecated
  • Instance methods
    1. __defineGetter__() Deprecated
    2. __defineSetter__() Deprecated
    3. __lookupGetter__() Deprecated
    4. __lookupSetter__() Deprecated
    5. toLocaleString()
    6. __proto__ Deprecated
    7. instanceof operator.

  • Syntax

    js
    func[Symbol.hasInstance](value)
    

    Parameters

    value

    The object to test. Primitive values always return false.

    Return value

    true if func.prototype is in the prototype chain of value; otherwise, false. Always returns false if value is not an object or this is not a function. If this is a bound function, returns the result of a instanceof test on value and the underlying target function.

    Exceptions

    TypeError

    Thrown if this is not a bound function and this.prototype is not an object.

    Description

    The [Symbol.hasInstance]() method of the right-hand side whenever such a method exists. Because all functions inherit from Function.prototype by default, they would all have the [Symbol.hasInstance]() method, so most of the time, the Function.prototype[Symbol.hasInstance]() method specifies the behavior of instanceof when the right-hand side is a function. This method implements the default behavior of the instanceof operator (the same algorithm when constructor has no [Symbol.hasInstance]() method).

    Unlike most methods, the Function.prototype[Symbol.hasInstance]() property is non-configurable and non-writable. This is a security feature to prevent the underlying target function of a bound function from being obtainable. See this Stack Overflow answer for an example.

    Examples

    Reverting to default instanceof behavior

    You would rarely need to call this method directly. Instead, this method is called by the instanceof operator. You should expect the two results to usually be equivalent.

    js
    class Foo {}
    const foo = new Foo();
    console.log(foo instanceof Foo === Foo[Symbol.hasInstance](foo)); / true
    

    You may want to use this method if you want to invoke the default instanceof behavior, but you don't know if a constructor has a overridden [Symbol.hasInstance]() method.

    js
    class Foo {
      static [Symbol.hasInstance](value) {
        / A custom implementation
        return false;
      }
    }
    
    const foo = new Foo();
    console.log(foo instanceof Foo); / false
    console.log(Function.prototype[Symbol.hasInstance].call(Foo, foo)); / true
    

    Specifications

    Specification
    ECMAScript® 2026 Language Specification
    # sec-function.prototype-%symbol.hasinstance%

    Browser compatibility

    See also

    • instanceof
    • Symbol.hasInstance

    Help improve MDN

    function keyword (as in function () { }) and arrow (=>) expression create functions. The JavaScript functions protocol includes default and rest parameters and binding to this.","name":"Functions"}},"browserCompat":["javascript.builtins.Function.@@hasInstance"],"pageType":"javascript-instance-method"}}

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant