union
은 2개 이상의 타입을 '허용'하는 경우이다.
or 의 개념으로 생각하면 된다.
let union : string | number;
union = 2;
union = 'hello';
intersection
은 2개 이상의 타입을 '조합'하는 경우이다.
and 의 개념으로 생각하면 된다.
interface Fruit {
name: string,
color: string
}
interface Price {
price: number
}
const apple: Fruit & Price = {
name: 'apple',
color: 'red',
price: 2000
}