I have this code:
class Obj {
constructor() {
this.foo = "foo";
}
}
Object.defineProperty(Obj.prototype,'foo',{enumerable:false,writable:true});
Object.defineProperty(Obj,'foo',{enumerable:false,writable:true});
let obj = new Obj();
console.log(obj);
And my output is:
Obj { foo: 'foo' }
The problem is, I defined the enumerable property as false for foo. But when in the construct I use 'this.foo' that property change it.
I know I can put in the constructor:
Object.defineProperty(this,'foo',{enumerable:false,writable:true});
And my new output throws correctly:
Obj {}
But, my question is if is possible to change once the property of foo and not change it in the constructor?
Thanks!
