Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_JavaScript/JavaScript_Destructuring.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

7.0 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
javascript-destructuring JavaScript Destructuring Frontend draft conceptual
destructuring
JS destructuring
destructuring assignment
object destructuring
array destructuring
rest property
B 0.89 2026-06-23 2026-06-23
javascript
js
web
frontend
w3schools
destructuring
es6
https://www.w3schools.com/js/js_destructuring.asp

JavaScript Destructuring

🎯 한 줄 통찰 (One-line insight)

Destructuring assignment unpacks objects and arrays (and any iterable) into individual variables without mutating the original — supporting defaults, aliases, skipping, position picks, and a rest property. [S1]

🧠 핵심 개념 (Core concepts)

  • Unpacks objects into variables — The destructuring assignment syntax can unpack objects into variables. [S1]
  • Order-independent for objects — When destructuring objects, the order of the properties does not matter. [S1]
  • Non-destructive — Destructuring is not destructive; it does not change the original object. [S1]
  • Default values — For potentially missing properties you can set default values. [S1]
  • Property aliases — A destructured property can be renamed into a different variable name. [S1]
  • Works on any iterable — Destructuring can be used with any iterables, including strings. [S1]
  • Array picks and skips — You can pick array variables, skip values with extra commas, and pick by specific index. [S1]
  • Rest property — Ending a destructuring with a rest property stores all remaining values into a new array. [S1]

🧩 추출된 패턴 (Extracted patterns)

  • {a, b} = obj — Object destructuring binds by property name, in any order. [S1]
  • {x = default} — Supply defaults inline for properties that may be missing. [S1]
  • {prop : alias} — Rename a property into a new variable. [S1]
  • [a,,,b] — Use extra commas to skip array positions. [S1]
  • {[0]:x ,[1]:y} — Pick array values by specific index. [S1]
  • [a, b, ...rest] — Collect remaining array values into rest. [S1]
  • [a, b] = [b, a] — Swap two variables in one statement. [S1]

📖 세부 내용 (Details)

Destructuring Assignment Syntax The destructuring assignment syntax can unpack objects into variables: [S1]

let {firstName, lastName} = person;

Object Destructuring [S1]

// Create an Object
const person = {
  firstName: "John",
  lastName: "Doe",
  age: 50
};

// Destructuring
let {firstName, lastName} = person;

The order of the properties does not matter: [S1]

// Create an Object
const person = {
  firstName: "John",
  lastName: "Doe",
  age: 50
};

// Destructuring
let {lastName, firstName} = person;

Destructuring is not destructive. Destructuring does not change the original object. [S1]

Object Default Values — For potentially missing properties we can set default values: [S1]

// Create an Object
const person = {
  firstName: "John",
  lastName: "Doe",
  age: 50
};

// Destructuring
let {firstName, lastName, country = "US"} = person;

Object Property Alias [S1]

// Create an Object
const person = {
  firstName: "John",
  lastName: "Doe",
  age: 50
};

// Destructuring
let {lastName : name} = person;

String Destructuring — One use for destructuring is unpacking string characters. Destructuring can be used with any iterables. [S1]

// Create a String
let name = "W3Schools";

// Destructuring
let [a1, a2, a3, a4, a5] = name;

Array Destructuring — We can pick up array variables into our own variables: [S1]

// Create an Array
const fruits = ["Bananas", "Oranges", "Apples", "Mangos"];

// Destructuring
let [fruit1, fruit2] = fruits;

Skipping Array Values — We can skip array values using two or more commas: [S1]

// Create an Array
const fruits = ["Bananas", "Oranges", "Apples", "Mangos"];

// Destructuring
let [fruit1,,,fruit2] = fruits;

Array Position Values — We can pick up values from specific index locations of an array: [S1]

// Create an Array
const fruits = ["Bananas", "Oranges", "Apples", "Mangos"];
// Destructuring
let {[0]:fruit1 ,[1]:fruit2} = fruits;

The Rest Property — You can end a destructuring syntax with a rest property. This syntax will store all remaining values into a new array: [S1]

// Create an Array
const numbers = [10, 20, 30, 40, 50, 60, 70];

// Destructuring
const [a,b, ...rest] = numbers

Destructuring Maps [S1]

// Create a Map
const fruits = new Map([
  ["apples", 500],
  ["bananas", 300],
  ["oranges", 200]
]);

// Destructuring
let text = "";
for (const [key, value] of fruits) {
  text += key + " is " + value;
}

Swapping JavaScript Variables — You can swap the values of two variables using a destructuring assignment: [S1]

let firstName = "John";
let lastName = "Doe";

// Destructuring
[firstName, lastName] = [lastName, firstName];

🛠️ 적용 사례 (Applied in summary)

The page's own snippets are the canonical applied examples — object/array destructuring, defaults, aliases, string and Map iteration, the rest property, and the variable-swap idiom. No external project/commit applications found in the source.

💻 코드 패턴 (Code patterns)

Object destructuring with default and alias (language: JavaScript):

let {firstName, lastName, country = "US"} = person;
let {lastName : name} = person;

Rest property collects the remainder:

const [a, b, ...rest] = numbers;

Swap two variables:

[firstName, lastName] = [lastName, firstName];

⚖️ 모순 및 업데이트 (Contradictions & updates)

No contradictions found in the source.

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.89
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Destructuring" page (Astra wiki-curation, P-Reinforce v3.1 format).