symbol_own_property.js (679B)
1 // Copyright (C) 2021 Jamie Kyle. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-object.hasown 6 description: Object.hasOwn called with symbol property key 7 info: | 8 Object.hasOwn ( _O_, _P_ ) 9 10 1. Let _obj_ be ? ToObject(_O_). 11 1. Let _key_ be ? ToPropertyKey(_P_). 12 ... 13 author: Jamie Kyle 14 features: [Symbol, Object.hasOwn] 15 ---*/ 16 17 var obj = {}; 18 var sym = Symbol(); 19 20 assert.sameValue( 21 Object.hasOwn(obj, sym), 22 false, 23 "Returns false if symbol own property not found" 24 ); 25 26 obj[sym] = 0; 27 28 assert.sameValue( 29 Object.hasOwn(obj, sym), 30 true, 31 "Returns true if symbol own property found" 32 ); 33 34 reportCompare(0, 0);