Files
2nd/10_Wiki/Topic_Programming/Topic_JavaScript/JavaScript_Destructuring.md
T
Antigravity Agent e9cbf23ab5 docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영.

- Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들
  (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거.
- Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/
  Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/
  Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이
  존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존).
- Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/
  JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동.
- 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리.
- Topic_Programming 최종 문서 수: 2784 → 3985.
2026-07-05 00:39:13 +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).