# Class Getter, Setter

## Class Getter, Setter 하기&#x20;

**여기서는 데이터원소, json 형태, (setter함수 ,getter함수)를 알아두는것이 포인트 입니다.**

```javascript
class TestClass {
    constructor(type, name, sound) {    //데이터 수정할려는 원소들만 신경쓴다.
        this.type = type;
        this.name = name;
        this.sound = sound;
    };
    get tion() {
        let fruits = [this.type, this.name, this.sound];
        return fruits.map((name, index) => {  //json 형태로 만들어서 배열로 반환하는 함수 
            return {
                id: index + 1,
                name,
                done: false
            }
        });
    };
    set tion(value) {    // 특정 원소를 변경하고자 하는 함수!
        this.name = value;
    };
}
const purpleCuteSlime = new TestClass('개나리','멍멍이', '멍멍');
purpleCuteSlime.tion = '스티븐 로저스'
console.log(purpleCuteSlime.tion)     //원소들 모두 조회 하기
console.log(purpleCuteSlime.tion[1].name)  //스티븐 로저스 조회하기
```

```javascript
// 결과)
[
  { id: 1, name: '개나리', done: false },
  { id: 2, name: '스티븐 로저스', done: false },
  { id: 3, name: '멍멍', done: false }
]
스티븐 로저스
```


---

# 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://triplexlab.gitbook.io/vanilla-js/basics/09-prototype-class/class-get-set.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.
