Skip to content
Related Articles

Related Articles

Improve Article
JavaScript TypeError – Property “X” is non-configurable and can’t be deleted
  • Last Updated : 31 Jul, 2020

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 #<Object> (Chrome)

Error Type:

TypeError

Cause of Error: There is an attempt to delete a property that is non-configurable.

Example 1: In this example, the delete is used to delete a non-configurable property, So the error has occurred.



HTML




<script>
    'use strict';
    var GFG_Obj = Object.freeze({prop1: 'val1', prop2: 123});
    delete GFG_Obj.prop2;  // Error here
</script>

Output(in console):

TypeError: Calling delete on 'prop2' is not allowed in strict mode

Example 2: In this example, the delete is used to delete PI which is a non-configurable property, So the error has occurred.

HTML




<script>
    'use strict';
    delete Math.PI;  // Error here
</script>

Output(in console):

TypeError: Calling delete on 'PI' is not allowed in strict mode

My Personal Notes arrow_drop_up
Recommended Articles
Page :