Open In App

JavaScript TypeError - Invalid 'instanceof' operand 'x'

Last Updated : 02 Jun, 2023
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

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.

JavaScript
"Geeks" instanceof ""; // error here

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.

JavaScript
function GFG() { }
let gfg = GFG();
let x = new GFG();
x instanceof gfg; // error here

Output:

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

Next Article

Similar Reads