# Object

{% tabs %}
{% tab title="📗 參考" %}
* TypeScript ⟩ [Object Types](https://www.typescriptlang.org/docs/handbook/2/objects.html)
{% endtab %}

{% tab title="👥 相關" %}
* [Cheat sheet](../cheatsheet)
{% endtab %}
{% endtabs %}

## Topics

* [Object Types](object/types)
* [Object Properties](object/properties)

## Object Types (Names) <a href="#types" id="types"></a>

{% hint style="info" %}
objects can be **anonymous**, named by using **interface** or **type**.
{% endhint %}

```typescript
// ⭐️ anonymous
//                     ╭──────── anonymous ────────╮
function greet(person: { name: string; age: number }) {
  return "Hello " + person.name;
}

// ⭐️ interface
interface Person {
  name: string;
  age : number;
}

// ⭐️ type alias
type Person = {
  name: string;
  age : number;
};
 
function greet(person: Person) {
  return "Hello " + person.name;
}
```
