JavaScript Symbol.hasInstance Property

The JavaScript Symbol.hasInstance is utilized to ascertain whether a constructor object identifies a particular object as an instance of itself.

Syntax

Example

[Symbol.hasInstance] (obj)

Parameters

An object as one of the constructor.

Return value

Return true if the specified value exists within the object's chain; otherwise, return false.

Browser Support

Chrome 5.1
Safari Yes
Firefox 50
Opera Yes

Example 1

Example

<script>

//JavaScript to illustrate Symbol.hasInstance

var pyVisualizer = [12,45];

document.write( Array[ Symbol.hasInstance ](pyVisualizer) );

//expected output:true

</script>

Output:

Example 2

Example

<script>

//JavaScript to illustrate Symbol.hasInstance

//Using user define function

function pyVisualizer()

{}

var Script = new PyVisualizer 

document.write( pyVisualizer[ Symbol.hasInstance ](Script) );

//expected output:true

</script>

Output:

Input Required

This code uses input(). Please provide values below: