# 10.3 셋 (Set)

### 셋의 특징

* 중복을 허용하지 않는 데이터 집합 => 추가하려는 것이 이미 있는지 확인할 필요 없음
* 만약 추가하려는 것이 이미 있다면?
  * 아무 일도 일어나지 않음

#### add() 메서드

* 데이터를 추가할 때

#### delete() 메서드

* 데이터를 삭제할 때
* 제거에 성공 => true, 실패 => false 반환

```javascript
  const roles = new Set();

  // 사용자 역할 추가
  roles.add("User");

  // 사용자에게 관리자 역할 추가
  roles.add("Admin");

  roles.size;

  console.log(roles); // Set(2) {"User", "Admin"}
  console.log(roles.size); // 3

  roles.delete("Admin");
  console.log(roles); // Set(1) {"User"}
```


---

# 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://april.gitbook.io/learning-js/chapter-10./10.3-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.
