frameworks/typescript

[typescript]type

iliosncelini 2018. 12. 6. 15:02
















































*undefined와 null은 모든 타입의 서프타입이기 때문에, 어떤 타입으로 선언된 변수에도 들어갈 수 있다.


1
2
3
4
5
6
7
8
9
10
11
12
13
class Person{
    name:string = null;
    age: number = null;
    constructor(name:string) {
        this.name = name;
    }
    hello(): void{
        console.log('what the hell');
    }
}
const person = new Person('mark');
console.log(person);
 
cs