Quiz 1.
type Person = {
name: string;
age: number;
};
let person: Person = {};
βοΈλ΅μ
let person: Person = {} as Person;
μ½λλ§ν¬
Quiz 2.
let value = 10;
giveMe10(value);
βοΈλ΅μ
let value = 10 as const;
giveMe10(value);
μ½λλ§ν¬
Quiz 3.
type Boss = {
car: string;
};
type Employee = {
salary: number;
};
type CompanyMember = Employee | Boss;
function test(companyMember: CompanyMember) {
if (companyMember.type === "Boss") {
console.log("μ¬μ₯λ λ μ°¨ λ°κΏ¨λ€ : ", companyMember.car);
} else if (companyMember.type === "Employee") {
console.log("μμ§λ μκΈμ : ", companyMember.salary);
}
}
βοΈλ΅μ
type Boss = {
type:"Boss";
car: string;
};
type Employee = {
type:"Employee";
salary: number;
};
μ½λλ§ν¬