JS: Object.isFrozen

JS: Object.isFrozen

Object.isFrozen(obj)

Return true if it is impossible to {add, delete, change} properties.

Technically, when all of the following is true:

  1. If the object's “extensible” attribute is false. (cannot add properties)
  2. If ALL of the object's own property's “configurable” attributes is false. (cannot delete properties)
  3. If ALL of the object's own property's “writable” attributes is false. (cannot change property values)

〔►see JS: Prevent Adding Property

〔►see JS: Object.freeze

const x3 = {};
console.log(Object.isFrozen(x3)); // false
Object.freeze(x3);
console.log(Object.isFrozen(x3)); // true

Reference

ECMAScript® 2016 Language Specification#sec-object.isfrozen

Like what you read? Buy JavaScript in Depth