728x90
๐ interface ์ฌ์ฉํ์ง ์๊ณ ์จ๋ณด๊ธฐ ์ฌ์ฉํ๊ณ ์จ๋ณด๊ธฐ
// do not use Interface
const getMathScore = (scoreObj: {math: number}): number => {
return scoreObj.math
}
const myScore = {korean: 85, math: 95, english: 87}
const myMathScore = getMathScore(myScore);
console.log(myMathScore)
๐๐ฝ 95
// do Interface
interface PhysicalValue {
physical: number;
}
const getPhysicalScore = (scoreObj: PhysicalValue) => {
return scoreObj.physical
}
const yourScore = {music: 87, art: 69, physical: 92}
const yourPhysicalScore = getPhysicalScore(yourScore);
console.log(yourPhysicalScore)
๐๐ฝ 92
๋ฐ์ํ
๋๊ธ