Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

TypeError: property "x" is non-configurable and can't be deleted

The JavaScript exception "property is non-configurable and can't be deleted" occurswhen it was attempted to delete a property, but that property isnon-configurable.

Message

TypeError: Cannot delete property 'x' of #<Object> (V8-based)TypeError: property "x" is non-configurable and can't be deleted (Firefox)TypeError: Unable to delete property. (Safari)

Error type

TypeError in strict mode only.

What went wrong?

It was attempted to delete a property, but that property isnon-configurable. Theconfigurable attribute controls whether the property can be deleted fromthe object and whether its attributes (other thanwritable) can be changed.

This error happens only instrict mode code. Innon-strict code, the operation returnsfalse.

Examples

Attempting to delete non-configurable properties

Non-configurable properties are not super common, but they can be created usingObject.defineProperty() orObject.freeze().

js
"use strict";const obj = Object.freeze({ name: "Elsa", score: 157 });delete obj.score; // TypeError
js
"use strict";const obj = {};Object.defineProperty(obj, "foo", { value: 2, configurable: false });delete obj.foo; // TypeError
js
"use strict";const frozenArray = Object.freeze([0, 1, 2]);frozenArray.pop(); // TypeError

There are also a few non-configurable properties built into JavaScript. Maybe you triedto delete a mathematical constant.

js
"use strict";delete Math.PI; // TypeError

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp