Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

TypeError: "x" is not a non-null object

The JavaScript exception "is not a non-null object" occurs when an object is expectedsomewhere and wasn't provided.null is not an object and won't work.

Message

TypeError: Property description must be an object: x (V8-based)TypeError: Property descriptor must be an object, got "x" (Firefox)TypeError: Property description must be an object. (Safari)

Error type

What went wrong?

An object is expected somewhere and wasn't provided.null is not anobject and won't work. You must provide a proper object in the given situation.

Examples

Property descriptor expected

When methods likeObject.create() orObject.defineProperty() andObject.defineProperties() areused, the optional descriptor parameter expects a property descriptor object. Providingno object (like just a number), will throw an error:

js
Object.defineProperty({}, "key", 1);// TypeError: 1 is not a non-null objectObject.defineProperty({}, "key", null);// TypeError: null is not a non-null object

A valid property descriptor object might look like this:

js
Object.defineProperty({}, "key", { value: "foo", writable: false });

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp