Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

JavaScript TypeError – Invalid ‘instanceof’ operand ‘x’

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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
My Personal Notes arrow_drop_up
Last Updated : 02 Jun, 2023
Like Article
Save Article
Similar Reads
Related Tutorials