
Union Type, Intersection Type, Etc...🙏(feat..optional chaining)
·
Typescript
Union TypeUnion 은 합집합이다. | 로 구분하고 javascript 의 OR 연산자와 비슷한 역활을 한다.(영단어 union 자체가 '합집합'이라는 뜻)type Marvel = "IronMan" | "Captain";type Dc = "Batman" | "Superman";type Hero = Marvel | Dc;// "IronMan" | "Captain" | "Batman" | "Superman" 모두 가능const iAm: Hero = "IronMan"; //OK타입 지정을 Hero로 하면 Marvel ,Dc 의 모든 영웅을 할당 할 수 있다.Intersection TypeIntersection 은 교집합이다. 여러 타입을 조합하여 하나의 타입으로 만들수 있다.교차 타입은 & 로 타입을..