JavaScript Class static
Keyword
Example
Example
The following example creates a class "tutorialpro" and a static method hello():
Definition and Usage
A class can define static methods using the static
keyword.
Static methods are called directly on the class and cannot be called on instances of the class.
Static methods are often used for creating utility functions.
Syntax
static methodName()
Technical Details
| JavaScript Version: | ECMAScript 2015 (ES6) |
Browser Support
static
is an ECMAScript6 (ES6) feature.
ES6 (JavaScript 2015) is supported by all major browsers.
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
Internet Explorer 11 or older versions do not support the static
keyword.