class Agent { static get CIRCLE() { return 1; } static get SQUARE() { return 2; } } console.log(Agent.CIRCLE); // 1
class Shape {
}
Shape.CIRCLE = 1;
Shape.SQUARE = 2;

console.log(Shape.CIRCLE); // 1
class MyClass {
static get MY_CONST() {
delete MyClass.MY_CONST;
return (MyClass.MY_CONST = 'string');
}
static set MY_CONST(value) {
delete MyClass.MY_CONST;
MyClass.MY_CONST = value;
}
get MY_CONST() {
return this.constructor.MY_CONST;
}
set MY_CONST(value) {
this.constructor.MY_CONST = value;
}
constructor() {
console.log(this.MY_CONST === this.constructor.MY_CONST);
}
}

console.log(MyClass.MY_CONST);
new MyClass();
// console: string, true
MyClass.MY_CONST = ['string', 42];
console.log(MyClass.MY_CONST);
new MyClass();
// console: string, 42 ; true

Leave a Reply