Expressions and patterns

Static class method

Try the free JavaScript compiler

Defines a method on the class constructor rather than its instance prototype. An ordinary static call supplies the constructor receiver.

Formal Syntax & Structure

javascript syntaxjavascript
static method(...args) { /* class-level behavior */ }

Working Example

Example Snippetjavascript
class C{static value(){return 5;}}console.log(C.value());
JavaScript Reference