It should be something like:
class C {
static m() { console.log('hi') }
}
// automatically run C.m
class D extends C { }
A python case is found. Is this possible in JavaScript?
It should be something like:
class C {
static m() { console.log('hi') }
}
// automatically run C.m
class D extends C { }
A python case is found. Is this possible in JavaScript?
2
Answers
In JS, you can’t automatically run code when a subclass is declared.
Javascript doesn’t have a metaclass per se, but you can create a pseudo metaclass by defining a class within a function: