lgcl-nullish-assignment-operator-non-extensible.js 651 B

123456789101112131415161718192021
  1. // Copyright (c) 2020 Ecma International. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: sec-assignment-operators-runtime-semantics-evaluation
  5. description: >
  6. Strict Mode - TypeError is thrown if The LeftHandSide of a Logical
  7. Assignment operator(??=) is a reference to a non-existent property
  8. of an object whose [[Extensible]] internal property is false.
  9. flags: [onlyStrict]
  10. features: [logical-assignment-operators]
  11. ---*/
  12. var obj = {};
  13. Object.preventExtensions(obj);
  14. assert.throws(TypeError, function() {
  15. obj.prop ??= 1;
  16. });
  17. assert.sameValue(obj.prop, undefined, "obj.prop");