Thuta Learning
ရှာဖွေရန်
IntermediateProgrammingintermediate

Objects

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

Object ၏ ပုံစံ (shape) ကို type annotation ဖြင့် သတ်မှတ်နိုင်သည်။ Object တွင် မည်သည့် properties များပါဝင်သင့်သည်၊ ၎င်းတို့၏ type များက ဘာလဲဆိုတာကို ကြိုတင်သတ်မှတ်ထားနိုင်သည်။

typescript
const person: { name: string; age: number } = {
  name: "John Doe",
  age: 30
};

console.log(`${person.name} is ${person.age} years old.`);
You should see
John Doe is 30 years old.