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


Example

here countInstance is a static class variable

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

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