Open In App

JavaScript TypeError – Invalid ‘instanceof’ operand ‘x’

Last Updated : 02 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads