1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15function* g() {} 16print(Object.getOwnPropertyDescriptor(g.__proto__, "constructor").configurable); 17print(Object.getOwnPropertyDescriptor(g.prototype.__proto__, "constructor").configurable); 18 19function FakeGeneratorFunctionConstructor() {} 20Object.defineProperty(g.__proto__, "constructor", {value: FakeGeneratorFunctionConstructor}); 21print(g.__proto__.constructor == FakeGeneratorFunctionConstructor); 22 23function FakeGeneratorObjectConstructor() {} 24Object.defineProperty(g.prototype.__proto__, "constructor", {value: FakeGeneratorObjectConstructor}); 25print(g.prototype.__proto__.constructor == FakeGeneratorObjectConstructor); 26 27const obj = { 28 name: '小明', 29 age: 20, 30 get fullName() { 31 return this.name; 32 } 33 }; 34 35const descriptors = Object.getOwnPropertyDescriptors(obj); 36print(descriptors.name.value === '小明'); 37print(descriptors.age.value === 20); 38print(typeof descriptors.fullName.get === 'function'); 39print(descriptors); 40