Skip to content
Related Articles

Related Articles

JavaScript TypeError – Invalid ‘instanceof’ operand ‘x’
  • Last Updated : 19 Aug, 2020

This JavaScript exception invalid ‘instanceof’ operand occurs if the right operand of the instanceof operator can not be used with a constructor object. It is an object that contains a prototype property and can be called.

Message:

TypeError: invalid 'instanceof' operand "x" (Firefox) 
TypeError: "x" is not a function (Firefox) 
TypeError: Right-hand side of 'instanceof' is not an object (Chrome) 
TypeError: Right-hand side of 'instanceof' is not callable (Chrome)

Error Type:

TypeError

Cause of the error: The right side of the instance operator is not a constructor object.

Example 1: In this example, the right side of instanceof operator is not a constructor object.



HTML




<script>
"Geeks" instanceof ""; // error here
</script>

Output:

TypeError: Right-hand side of 'instanceof' is not an object

Example 2: In this example, the right side of instanceof operator is not a constructor object.

HTML




<script>
function GFG() {}
var gfg = GFG();   
var x = new GFG();
x instanceof gfg; // error here
</script>

Output:

TypeError: Right-hand side of 'instanceof' is not an object
My Personal Notes arrow_drop_up
Recommended Articles
Page :