9609c04755
W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더). - Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외) - Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체) - Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속) 각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
146 lines
5.8 KiB
Markdown
146 lines
5.8 KiB
Markdown
---
|
|
id: javascript-set-logic
|
|
title: "JavaScript Set Logic"
|
|
category: "Frontend"
|
|
status: "draft"
|
|
verification_status: "conceptual"
|
|
canonical_id: ""
|
|
aliases: ["Set logic", "union", "intersection", "difference", "symmetricDifference", "isSubsetOf", "isDisjointFrom"]
|
|
duplicate_of: ""
|
|
source_trust_level: "B"
|
|
confidence_score: 0.88
|
|
created_at: 2026-06-23
|
|
updated_at: 2026-06-23
|
|
review_reason: ""
|
|
merge_history: []
|
|
tags: ["javascript", "js", "web", "frontend", "w3schools", "set", "set-logic"]
|
|
raw_sources: ["https://www.w3schools.com/js/js_set_logic.asp"]
|
|
applied_in: []
|
|
github_commit: ""
|
|
---
|
|
|
|
# [[JavaScript Set Logic]]
|
|
|
|
## 🎯 한 줄 통찰 (One-line insight)
|
|
JavaScript 2025 added seven set-theory methods to `Set` — `union`, `intersection`, `difference`, `symmetricDifference` (returning new Sets) and `isSubsetOf`, `isSupersetOf`, `isDisjointFrom` (returning booleans) — for direct mathematical set operations. [S1]
|
|
|
|
## 🧠 핵심 개념 (Core concepts)
|
|
- **Seven logical Set methods** were added to the Set object in JavaScript 2025. [S1]
|
|
- **Combining methods return a new Set** — `union`, `intersection`, `difference`, `symmetricDifference`. [S1]
|
|
- **Relationship methods return a boolean** — `isSubsetOf`, `isSupersetOf`, `isDisjointFrom`. [S1]
|
|
- **Each operates on this Set and an argument Set** — e.g. `A.union(B)`. [S1]
|
|
- **Browser support is recent** — Chrome/Edge 136 (Apr 2025), Firefox 129 (Aug 2024), Safari 18.2 (Dec 2024), Opera 120 (May 2025). [S1]
|
|
|
|
## 🧩 추출된 패턴 (Extracted patterns)
|
|
- **Binary set operation** — call a method on set A passing set B: `const C = A.intersection(B);`. [S1]
|
|
- **New-Set vs predicate** — combining ops yield a Set you store; relationship ops yield a `true`/`false` you store in `answer`. [S1]
|
|
|
|
## 📖 세부 내용 (Details)
|
|
**union()** — returns a new set containing the elements which are in this set, or in the argument set, or in both: [S1]
|
|
```javascript
|
|
const A = new Set(['a','b','c']);
|
|
const B = new Set(['b','c','d']);
|
|
|
|
const C = A.union(B);
|
|
```
|
|
|
|
**intersection()** — returns a new set containing the elements which are in this set and in the argument set: [S1]
|
|
```javascript
|
|
const A = new Set(['a','b','c']);
|
|
const B = new Set(['b','c','d']);
|
|
|
|
const C = A.intersection(B);
|
|
```
|
|
|
|
**difference()** — returns a new set containing elements which are in this set but not in the argument set: [S1]
|
|
```javascript
|
|
const A = new Set(['a','b','c']);
|
|
const B = new Set(['b','c','d']);
|
|
|
|
const C = A.difference(B);
|
|
```
|
|
|
|
**symmetricDifference()** — returns a new set containing elements which are in this set or in the argument set, but not in both: [S1]
|
|
```javascript
|
|
const A = new Set(['a','b','c']);
|
|
const B = new Set(['b','c','d']);
|
|
|
|
const C = A.symmetricDifference(B);
|
|
```
|
|
|
|
**isSubsetOf()** — returns `true` if all elements in this set is also elements in the argument set: [S1]
|
|
```javascript
|
|
const A = new Set(['a','b','c']);
|
|
const B = new Set(['b','c','d']);
|
|
|
|
let answer = A.isSubsetOf(B);
|
|
```
|
|
|
|
**isSupersetOf()** — returns `true` if all elements in the argument set are also in this set: [S1]
|
|
```javascript
|
|
const A = new Set(['a','b','c']);
|
|
const B = new Set(['b','c','d']);
|
|
|
|
let answer = A.isSupersetOf(B);
|
|
```
|
|
|
|
**isDisjointFrom()** — returns `true` if this set has no elements in common with the argument set: [S1]
|
|
```javascript
|
|
const A = new Set(['a','b','c']);
|
|
const B = new Set(['b','c','d']);
|
|
|
|
let answer = A.isDisjointFrom(B);
|
|
```
|
|
|
|
**Browser Support** — JavaScript Set Logic methods are supported in modern browsers from 2024-2025: [S1]
|
|
|
|
| Browser | Version | Release |
|
|
|---------|---------|---------|
|
|
| Chrome | 136 | Apr 2025 |
|
|
| Edge | 136 | Apr 2025 |
|
|
| Firefox | 129 | Aug 2024 |
|
|
| Safari | 18.2 | Dec 2024 |
|
|
| Opera | 120 | May 2025 |
|
|
|
|
## 🛠️ 적용 사례 (Applied in summary)
|
|
The page's own snippets are the canonical applied examples — running each operation over two fixed Sets `A = {a,b,c}` and `B = {b,c,d}`, storing combining results in `C` and relationship results in `answer`. No external project/commit applications found in the source.
|
|
|
|
## 💻 코드 패턴 (Code patterns)
|
|
Intersection of two Sets (language: JavaScript):
|
|
```javascript
|
|
const C = A.intersection(B);
|
|
```
|
|
Subset predicate:
|
|
```javascript
|
|
let answer = A.isSubsetOf(B);
|
|
```
|
|
|
|
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
|
Choose the method by the question being asked, per the source definitions: [S1]
|
|
- Need everything from both → `union()`.
|
|
- Need only shared elements → `intersection()`.
|
|
- Need this set minus the other → `difference()`.
|
|
- Need elements unique to one side (the XOR) → `symmetricDifference()`.
|
|
- Just need a yes/no relationship → `isSubsetOf()`, `isSupersetOf()`, or `isDisjointFrom()` (boolean, no new Set produced).
|
|
|
|
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
|
These are new additions (JavaScript 2025). Older runtimes predating the browser versions listed will not have them. No contradictions found in the source. [S1]
|
|
|
|
## ✅ 검증 상태 및 신뢰도
|
|
- **상태:** draft
|
|
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
|
|
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
|
- **신뢰 점수:** 0.88
|
|
- **중복 검사 결과:** 신규 생성 (New discovery)
|
|
|
|
## 🔗 지식 그래프 (Knowledge Graph)
|
|
- **상위/루트:** [[JavaScript Tutorial]]
|
|
- **관련 개념:** [[JavaScript Sets]], [[JavaScript Set Methods]], [[JavaScript Maps]]
|
|
- **참조 맥락:** Referenced when performing mathematical set operations between two Sets.
|
|
|
|
## 📚 출처 (Sources)
|
|
- [S1] W3Schools — JavaScript Set Logic — https://www.w3schools.com/js/js_set_logic.asp
|
|
|
|
## 📝 변경 이력 (Change history)
|
|
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Set Logic" page (Astra wiki-curation, P-Reinforce v3.1 format).
|