'use strict';
const __PROP = Symbol();
class Foo {
constructor() {
Object.getOwnPropertyNames(this.__proto__).forEach((key) => {
var descriptor = Object.getOwnPropertyDescriptor(this.__proto__, key);
if (descriptor && (typeof descriptor.get === "function" || typeof descriptor.set === "function")) {
descriptor.enumerable = true;
Object.defineProperty(this, key, descriptor);
}
});
this.prop = 1;
}
get prop() {
return this[__PROP];
}
set prop(value) {
this[__PROP] = value;
}
}
let bar = new Foo();
console.log(bar.prop); // 1
console.log(Object.keys(bar)); // ["prop"]