AI
Size: a a a
AI
MA
AI
MA
MA
DK
{
a: 1,
b: a? + 2
}
RD
DK
RD
RD
DK
DL
M
const obj = new (function() {
this.a = 1;
this.b = this.a + 1;
})()
разве что такDK
DK
MA
АМ
// MDN
var o = { a: 0 };
Object.defineProperties(o, {
'b': { get: function() { return this.a + 1; } },
'c': { set: function(x) { this.a = x / 2; } }
});
o.c = 10; // Runs the setter, which assigns 10 / 2 (5) to the 'a' property
console.log(o.b); // Runs the getter, which yields a + 1 or 6
АМ
MA
DK