A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-136.js
1classC{
2staticcount=0;
3staticinc(){this.count++;returnthis.count;}
4}
5console.log(C.inc(),C.inc());
Scope
Answer & explanation
Console output
1 2
Why
In a static method, this is bound to the class (the constructor function) when the method is invoked as C.inc(). So this.count reads and writes the static field on C, giving a single shared counter that yields 1 then 2. This is why static methods can maintain class-level state through this.