# TS - Object

<figure><img src="/files/1J3RXu4Q2QYglD9pHtIT" alt=""><figcaption></figcaption></figure>

ရိုးရိုး JavaScript မှာလိုပဲ Object တစ်ခု Key-Value Pairs တွေနဲ့ တည်ဆောက်ပါတယ်

Object Type ကို ရေးသား ဖို့အတွက် TypeScript မှာ Property နဲ့ ValueType ကို သတ်မှတ်ရေးသားကြပါတယ် ။

### Object Type Annotation

<figure><img src="/files/vdwyAzfeI5NKD2sHPmbC" alt=""><figcaption></figcaption></figure>

const `person` ရဲ့နောက်မှာ object type အဖြစ် ဆိုင်ရာ property တွေနဲ့ type တွေ အရင်သတ်မှတ်လိုက်ပါတယ် ။ ပြီးတဲ့နောက်မှာ တန်ဖိုးကို Assign လုပ်လိုက်ပါတယ် ။ အောက်က Code အတိုင်းဖြစ်သွားမှာပါ ။

```typescript
const person: {
  name: string;
  age: number;
  status: "active" | "inactive";
} = {
  name: "Lwin",
  age: 28,
  status: "active",
};
```

စာဖတ်သူတို့က property အသစ် isAdmin (boolean) type ထည့်ပေးပါ ။&#x20;

အဖြေကတော့ အောက်ပါ Code အတိုင်း ရလာမှာဖြစ်ပါတယ် ။

```typescript
const person: {
  name: string;
  age: number;
  status: "active" | "inactive";
  isAdmin: boolean;
} = {
  name: "Lwin",
  age: 28,
  status: "active",
  isAdmin: true,
};
```

### Optional Properties

<figure><img src="/files/bKMVezmg11IMMxIIFDQj" alt=""><figcaption></figcaption></figure>

Object ထဲက တချို့ property တွေ မဖြည့်လည်း ရအောင် `?` (question mark) ကို သုံးနိုင်ပါတယ်။

နမူနာ code ထဲမှာ `age` , `status` ရယ်ကို `?:` သုံးပြီး ရေးသားလိုက်တဲ့အတွက်  Assign  မထည့်ဘဲ ရေးသားနိုင် သွားပါတယ်။


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lwin-moe-paing.gitbook.io/typescript-baby-by-lwin-moe-paing/basic-typescript/ts-object.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
