2 靜態類變數示例 - 計算呼叫的方法數
這裡 countInstance 是一個靜態類變數
class StaticTest{
static countInstance : number= 0;
constructor(){
StaticTest.countInstance++;
}
}
new StaticTest();
new StaticTest();
console.log(StaticTest.countInstance);
這裡 countInstance 是一個靜態類變數
class StaticTest{
static countInstance : number= 0;
constructor(){
StaticTest.countInstance++;
}
}
new StaticTest();
new StaticTest();
console.log(StaticTest.countInstance);