타입을 부여하는 행위를 타이핑이라 표현함
기본 타입
stringnumberbooleannullundefinedsymbolbigintobjectconst str: string = "hello";
const num: number = 123;
const bool: boolean = false;
const n: null = null;
const u: undefined = undefined;
const sym: symbol = Symbol("sym");
const big: bigint = 1000000000n;
const obj: Object = {hello: "world"};
→ bigint는 ES2020 이상의 자바스크립트에서만 동작함
함수는 매개변수의 타입은 매개변수 뒤 표기, 반환값의 타입은 함수의 매개변수 소괄호 뒤에
function plus(x: number, y: number): number {
return x + y;
}
const minus = (x: number, y: number): number => x - y;