JS: Class static fields and methods
Class members can be declared with a static keyword in front.
For example
static var_name;static var_name = value;static method_name (params) {body}static get getter_name () {body}static set setter_name (params) {body}
Static members becomes properties of the class constructor function.
Example
// verify static member behavior of a class class Burger { static bread = 2; static add_bread(x) { console.log("add_bread called with arg " + x); Burger.bread = Burger.bread + x; } } // s------------------------------ // all static members are properties of the constructor // has property bread console.assert( Object.hasOwn(Burger, "bread"), ); // has property add_bread console.assert( Object.hasOwn(Burger, "add_bread"), );