Objects
Array က စာရင်း (List) တစ်ခု လုပ်ဖို့ ကောင်းပေမယ့်၊ ပစ္စည်းတစ်ခုရဲ့ အသေးစိတ် အချက်အလက်တွေ (Properties) ကို သိမ်းဖို့ကျတော့ Object က ပိုကောင်းပါတယ်။ (ဥပမာ - လူတစ်ယောက်ရဲ့ နာမည်၊ အသက်၊ အရပ်)
Creating Objects (Object တည်ဆောက်ခြင်း)
Section titled “Creating Objects (Object တည်ဆောက်ခြင်း)”Object ကို {} (Curly Braces) နဲ့ ရေးပါတယ်။ အတွဲလိုက် Key-Value Pair ပုံစံနဲ့ ရှိပါတယ်။
let person = { name: "Mg Mg", age: 20, isStudent: true, hobbies: ["Reading", "Gaming"]};name,ageဆိုတာ Keys (Properties)"Mg Mg",20ဆိုတာ Values
Accessing Properties (Data ယူသုံးခြင်း)
Section titled “Accessing Properties (Data ယူသုံးခြင်း)”နည်းလမ်း (၂) မျိုး ရှိပါတယ်။
1. Dot Notation (အသုံးအများဆုံး) .
Section titled “1. Dot Notation (အသုံးအများဆုံး) .”console.log(person.name); // "Mg Mg"console.log(person.age); // 202. Bracket Notation []
Section titled “2. Bracket Notation []”console.log(person["name"]); // "Mg Mg"Modifying Objects (ပြုပြင်ခြင်း)
Section titled “Modifying Objects (ပြုပြင်ခြင်း)”// တန်ဖိုး ပြောင်းမယ်person.age = 21;
// အသစ် ထပ်ထည့်မယ်person.city = "Yangon";
// ဖျက်မယ်delete person.isStudent;
console.log(person);