Typescript 문법 class/extends/function/Literal types/Union types/intersection types/Generics)
1. class 정의 클래스는 implements 를 사용한다 interface Car{ color:string; // 타입이 string인 함수 wheels:number; // 타입이 number인 함수 start():void; // return 값이 없는 함수 } class Bmw implements Car{ color;// 멤버 변수 wheels=4; // js 와 다르게 class 의 멤머변수를 설정할 때 constructor 외부에서도 변수선언을 해주어야 한다 constructor(c:string){ // 생성자 함수 this.color=c; } start():void{// 멤버 함수 console.log('go....!'); } } const car1 = new Bmw('green'); con..
2022.11.03