<aside> 📌 타입을 부여하는 타이핑 (Typing) 예시들
</aside>
const str: string = 'hello';
const num: number = 123;
const bool: boolean = true;
const n: null = null;
const u: undefined = undefined;
const sym: symbol = Symbol('sym');
const big: bigint = 100000000n;
const obj: object = { hello: 'world' };
bigint
는 ES2020에서 추가된 타입symbol
은 ES2015에서 추가된 타입// 함수 선언식
function plus(x: number, y: number): number {
return x + y;
}
// 화살표 함수
const minus = (x: number, y: number): number => x - y;
()
뒤에 표기