Skip to content
Related Articles

Related Articles

Improve Article

JavaScript | Symbol.hasInstance Property

  • Last Updated : 06 May, 2019

The Symbol.hasInstance is an inbuilt property in JavaScript which is used to determine if a given constructor object recognizes the object as its instance.



Parameters: It accepts a parameter “object”.

Return value: This returns true if the value is in the chain of the object otherwise false.

JavaScript code to show the working of this function.

   // Initialising some objects
   var obj1 = [1, 2, 3]; 
   var obj2 = ['a', 'b', 'c']; 
   var obj3 = [123]; 
   var obj4 = []; 
   // Calling Symbol.hasInstance Property 
   console.log( Array[Symbol.hasInstance](obj1));
   console.log( Array[Symbol.hasInstance](obj2));
   console.log( Array[Symbol.hasInstance](obj3));
   console.log( Array[Symbol.hasInstance](obj4));


> true
> true
> true
> true


    // Calling a user define function  
    function gfg()  
    // Initialising the object
    var Script = new gfg  
    // Calling the Symbol.hasInstance property


> true

Supported Browsers:

  • Google Chrome 51
  • Firefox 50
  • Edge 15
  • Opera
  • Apple Safari


My Personal Notes arrow_drop_up
Recommended Articles
Page :