lgcl-or-assignment-operator-non-writeable-put-strict.js (767B)
1 'use strict'; 2 // Copyright (c) 2020 Ecma International. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-assignment-operators-runtime-semantics-evaluation 7 description: > 8 Strict Mode - TypeError is thrown if the LeftHandSide of a Logical 9 Assignment operator(||=) is a reference to a data property with the 10 attribute value {[[Writable]]:false} and PutValue step is reached. 11 flags: [onlyStrict] 12 features: [logical-assignment-operators] 13 14 ---*/ 15 16 var obj = {}; 17 Object.defineProperty(obj, "prop", { 18 value: 0, 19 writable: false, 20 enumerable: true, 21 configurable: true 22 }); 23 24 assert.throws(TypeError, function() { 25 obj.prop ||= 1; 26 }); 27 assert.sameValue(obj.prop, 0, "obj.prop"); 28 29 reportCompare(0, 0);