이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 참여해서 번역을 마치도록 도와 주세요!
English (US)의 문서도 읽어보세요.

Message

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

What went wrong?

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

Examples

Property descriptor expected

When methods like Object.create() or Object.defineProperty() and Object.defineProperties() are used, the optional descriptor parameter expects a property descriptor object. Providing no object (like just a number), will throw an error:

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

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

A valid property descriptor object might look like this:

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

WeakMap and WeakSet objects require object keys

WeakMap and WeakSet objects store object keys. You can't use other types as keys.

var ws = new WeakSet();
ws.add('foo');
// TypeError: "foo" is not a non-null object

Use objects instead:

ws.add({foo: 'bar'});
ws.add(window);

See also

문서 태그 및 공헌자

 이 페이지의 공헌자: fscholz
 최종 변경: fscholz,