Open In App

JavaScript TypeError – “X” is not a non-null object

Last Updated : 22 May, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

This JavaScript exception is not a non-null object that occurs if an object is not passed where it is expected. So the null is passed which is not an object and it will not work.

Message:

TypeError: Invalid descriptor for property {x} (Edge)
TypeError: "x" is not a non-null object (Firefox)
TypeError: Property description must be an object: "x" (Chrome)
TypeError: Invalid value used in weak set (Chrome)

Error Type:

TypeError

Cause of Error: Somewhere in the code an object is expected and is not passed. Automatically null is passed which is not an object and it will not work. The user needs to provide a proper object in the given context.

Example 1: In this example, 1 is passed in the given method which is a non-null object, So the error has occurred.

Javascript




// 1 is non-null object
Object.defineProperty({}, 'prop_name', 1);


Output(In Chrome console):

TypeError: Property description must be an object: 1

Example 2: In this example, the WeakSet object store object keys, Other types of keys are not accepted. So the error has occurred.

Javascript




let var1 = new WeakSet();
var1.add('GFG');


Output(In Chrome console):

TypeError: Invalid value used in weak set

Previous Article
Next Article

Similar Reads

JavaScript TypeError - Can't assign to property "X" on "Y": not an object
This JavaScript exception can't assign to property occurs in strict-mode only and this error occurs If the user tries to create a property on any of the primitive values like a symbol, a string, a number, or a boolean. Primitive values cannot be used to hold any property. Message: TypeError: can't assign to property "x" on {y}: not an object (Firef
1 min read
JavaScript TypeError - Property "X" is non-configurable and can't be deleted
This JavaScript exception property is non-configurable and can't be deleted if the user tries to delete a property, and the property is non-configurable. Message: TypeError: Calling delete on 'x' is not allowed in strict mode (Edge) TypeError: property "x" is non-configurable and can't be deleted. (Firefox) TypeError: Cannot delete property 'x' of
1 min read
JavaScript TypeError - Can't redefine non-configurable property "x"
This JavaScript exception can't redefine non-configurable property occurs if user tries to redefine a property, but that property is non-configurable. Message: TypeError: Cannot modify non-writable property {x} (Edge) TypeError: can't redefine non-configurable property "x" (Firefox) TypeError: Cannot redefine property: "x" (Chrome) Error Type: Type
1 min read
JavaScript TypeError - Can't delete non-configurable array element
This JavaScript exception can't delete non-configurable array element that occurs if there is an attempt to short array-length, and any one of the array's elements is non-configurable. Message: TypeError: can't delete non-configurable array element (Firefox) TypeError: Cannot delete property '2' of [object Array] (Chrome) Error Type: TypeError Caus
1 min read
JavaScript TypeError - Cyclic object value
This JavaScript exception cyclic object value occurs if the references of objects were found in JSON. JSON.stringify() fails to solve them. Message: TypeError: cyclic object value (Firefox) TypeError: Converting circular structure to JSON (Chrome and Opera) TypeError: Circular reference in value argument not supported (Edge) Error Type: TypeError C
1 min read
JavaScript TypeError - "X" is (not) "Y"
This JavaScript exception X is (not) Y occurs if there is a data type that is not expected there. Unexpected is undefined or null values. Message: TypeError: Unable to get property {x} of undefined or null reference (Edge) TypeError: "x" is (not) "y" (Firefox) Few example are given below: TypeError: "x" is undefined TypeError: "y" is null TypeError
1 min read
JavaScript TypeError - "X" is not a constructor
This JavaScript exception is not a constructor that occurs if the code tries to use an object or a variable as a constructor, which is not a constructor. Message: TypeError: Object doesn't support this action (Edge) TypeError: "x" is not a constructor TypeError: Math is not a constructor TypeError: JSON is not a constructor TypeError: Symbol is not
1 min read
JavaScript TypeError - "X" is not a function
This JavaScript exception is not a function that occurs if someone trying to call a value from a function, but in reality, the value is not a function. Message: TypeError: Object doesn't support property or method {x} (Edge) TypeError: "x" is not a function Error Type: TypeError Cause of Error: There is an attempt to call a value from a function, b
1 min read
JavaScript TypeError - 'X' is not iterable
This JavaScript exception is not iterable occurs if the value present at the right-hand-side of for…of or as argument of a function such as Promise.all or TypedArray.from, can not be iterated or is not an iterable object. Message: TypeError: 'x' is not iterable (Firefox, Chrome) TypeError: 'x' is not a function or its return value is not iterable (
1 min read
JavaScript TypeError - Can't define property "X": "Obj" is not extensible
This JavaScript exception can't define property "x": "obj" is not extensible occurs when Object.preventExtensions() is used on an object to make it no longer extensible, So now, New properties can not be added to the object. Message: TypeError: Cannot create property for a non-extensible object (Edge) TypeError: can't define property "x": "obj" is
1 min read