static class variable example - count how many time method is being invoked

suggest change

here countInstance is a static class variable

class StaticTest{
    static countInstance : number= 0;
    constructor(){
        StaticTest.countInstance++;
    }
}

new StaticTest();
new StaticTest();
console.log(StaticTest.countInstance);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents