객체지향

    [TypeScript] 객체지향 프로그래밍

    [TypeScript] 객체지향 프로그래밍

    ※ Javascript에서의 객체지향과 크게 다르지 않습니다. TypeScript만의 객체지향을 말하는것이 아니니 주의해 주세요. 1. 클래스(Class) TypeScript에서 클래스는 아래와 같이 생성합니다. class Car { color: string = 'red'; speed: number = 0; Drive(acc): void { this.speed += acc; console.log('speed : ', this.speed); }; Stop(): void { this.speed = 0; console.log('stop'); }; }; const car = new Car(); console.log(car.color); Car라는 클래스는 color와 speed라는 멤버변수와 Drive(), S..