🔰nested type

JSvaluetype ⟩ nested type

replit ⟩ nested type in JS

// A
class A {

    // ⭐️ nested type: A.B
    static B = class {
        
        // 🟦 static method
        static sayHi() { console.log('Hi') }
        
        // 🔹 instance method
        instanceSayHi() { console.log('Hi, I am an instance of A.B !') }
    };
    
}

// test code
A.B.sayHi();                  // Hi
(new A.B).instanceSayHi();    // Hi, I am an instance of A.B !

Last updated