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.
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;
|
Output:
TypeError: Right-hand side of 'instanceof' is not an object