Constconst obj = {};
expect(obj, 'to be extensible'); // ✓ passes - objects are extensible by default
obj.newProp = 'value'; // This works
Object.preventExtensions(obj);
expect(obj, 'to be extensible'); // ✗ fails - no longer extensible
const sealed = Object.seal({});
expect(sealed, 'to be extensible'); // ✗ fails - sealed objects are non-extensible
const frozen = Object.freeze({});
expect(frozen, 'to be extensible'); // ✗ fails - frozen objects are non-extensible
Asserts that an object is extensible using
Object.isExtensible().An extensible object allows new properties to be added to it. This is the default state for objects, but can be disabled using
Object.preventExtensions(),Object.seal(), orObject.freeze(). This assertion is useful for testing that an object hasn't been made non-extensible by any of these operations.