728x90 타입스크립트 static1 [typescript / 타입스크립트] class 내 static 사용하기 [Typescript / 타입스크립트] Class 내 Static 사용하기 class 내 객체 생성시마다 함께 생성되는 멤버 변수를 static 화 하여 생성시마다 생기는 메모리 누수를 막아보자 type InCoffee = { shots : number; } ////멤버 변수만 사용한 경우 class Coffee { gram_per_shot :number = 10; beans :number = 0; constructor (beans:number) { this.beans = beans; } makeCoffee(shots:number):InCoffee { if(this.beans < shots * this.gram_per_shot){ console.error('원두 부족'); } return { shots .. 2021. 11. 16. 이전 1 다음 728x90