MDN wants to learn about developers like you:

Наші добровольці ще не переклали статтю цією мовою: Українська. Долучайтеся й допоможіть це зробити!
Ви також можете прочитати цю статтю іншою мовою: English (US).

The static keyword defines a static method for a class.


static methodName() { ... }


Static method calls are made directly on the class and are not callable on instances of the class. Static methods are often used to create utility functions.

Calling static methods

From another static method

In order to call a static method within another static method of the same class, you can use the this keyword.

class StaticMethodCall {
  static staticMethod() {
    return 'Static method has been called';
  static anotherStaticMethod() {
    return this.staticMethod() + ' from another static method';
// 'Static method has been called'

// 'Static method has been called from another static method'

From class constructor and other methods

Static methods are not directly accessible using the this keyword from non-static methods. You need to call them using the class name: CLASSNAME.STATIC_METHOD_NAME() or by calling the method as a property of the constructorthis.constructor.STATIC_METHOD_NAME().

class StaticMethodCall {
  constructor() {
    // 'static method has been called.' 

    // 'static method has been called.' 

  static staticMethod() {
    return 'static method has been called.';


The following example demonstrates several things:

  1. How a static method is implemented on a class.
  2. That a class with a static member can be sub-classed.
  3. How a static method can and cannot be called.
class Triple {
  static triple(n) {
    if (n === undefined) {
      n = 1;
    return n * 3;

class BiggerTriple extends Triple {
  static triple(n) {
    return super.triple(n) * super.triple(n);

console.log(Triple.triple());        // 3
console.log(Triple.triple(6));       // 18

var tp = new Triple();

// 81 (not affected by parent's instantiation)

// 'tp.triple is not a function'.


Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Class definitions' in that specification.
Standard Initial definition.
ECMAScript Latest Draft (ECMA-262)
The definition of 'Class definitions' in that specification.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support4911345 No439
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support ? Yes1345 ?9 ?

1. From Chrome 42 to 48 strict mode is required. Non-strict mode support can be enabled using the flag "Enable Experimental JavaScript".

See also

Мітки документа й учасники

 Востаннє оновлена: wbamberg,