Mascara: Next Generation JavaScript compiler

Try it Download Buy About Documentation Blog Contact

Static members

Static members are members which belong to a class rather than an instance. They are declared with the attribute static.

class A {
    static function f() {} // static function
    static var x = 100; // static field
}

Static members are accessed by prefixing with the class name:

   A.f();
   A.x = 1001;

The class name can be left out when static members are accessed from inside the same class where they are defined:

class A {
    static var x = 100;
    static function() {
        x = 1001;
    }

Static members can have the access modifiers public or private.

X Try!
Mascara JavaScript Generated JavaScript

Translating...
Show compiler settings