# 속성 Setters

세터(setter)/게터(getter) 말고 명시적인 함수 (예: `setBar`, `getBar` 함수)를 사용하는 것이 좋습니다.

다음 코드를 보세요:

```typescript
foo.bar = {
    a: 123,
    b: 456
};
```

게터/세터 대신:

```typescript
class Foo {
    a: number;
    b: number;
    set bar(value:{a:number,b:number}) {
        this.a = value.a;
        this.b = value.b;
    }
}
let foo = new Foo();
```

이것은 속성 세터를 사용하는 *좋은* 예가 아닙니다. 첫번째 코드 샘플을 읽는 사람은 무엇이 변경되는지 전체 맥락을 알 수 없습니다. 반면 `foo.setBar(value)` 라고 호출하는 사람은 자신이 `foo` 의 무언가를 변경하고 있다고 생각할 수 있을 것입니다.

> 보너스 포인트: 여러가지 함수를 사용하면 참조를 찾기도 더 쉽습니다. TypeScript 툴에서 게터 또는 세터의 레퍼런스를 찾으면 *두가지* 경우가 모두 나오게 되지만 명시적 함수 호출을 사용하면 원하는 함수에 대한 참조만 볼 수 있습니다.


---

# 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://radlohead.gitbook.io/typescript-deep-dive/main-1/propertysetters.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.
