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.
This commit is contained in:
Antigravity Agent
2026-07-05 00:39:13 +09:00
parent 9148c358d0
commit e9cbf23ab5
1356 changed files with 0 additions and 12831 deletions
@@ -0,0 +1,179 @@
---
id: javascript-array-const
title: "JavaScript Array Const"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["const array", "constant array", "const block scope", "const reassignment", "array const declaration"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.89
created_at: 2026-06-23
updated_at: 2026-06-23
review_reason: ""
merge_history: []
tags: ["javascript", "js", "web", "frontend", "w3schools", "array", "const"]
raw_sources: ["https://www.w3schools.com/js/js_array_const.asp"]
applied_in: []
github_commit: ""
---
# [[JavaScript Array Const]]
## 🎯 한 줄 통찰 (One-line insight)
A `const` array cannot be *reassigned*, but its *elements* can be changed, added, or removed — `const` protects the binding, not the contents. [S1]
## 🧠 핵심 개념 (Core concepts)
- **`const` is common practice for arrays** — ES2015 (ES6) made declaring arrays with `const` standard practice. [S1]
- **A const array cannot be reassigned** — assigning a new array to the same `const` name is an ERROR. [S1]
- **Const array elements CAN change** — you can change, add (`push`), or remove elements of a `const` array. [S1]
- **Const must be assigned when declared** — declaring without assignment is a syntax error. [S1]
- **Const has block scope** — a `const` declared inside a block is not the same variable as one outside the block. [S1]
- **Const cannot be redeclared** — you cannot redeclare or reassign a `const` in the same scope, but you can declare a new `const` with the same name in a different block scope. [S1]
## 🧩 추출된 패턴 (Extracted patterns)
- **Mutate-not-rebind pattern** — use `const` for arrays you will mutate in place (`cars[0] = ...`, `cars.push(...)`) but never reassign. [S1]
- **Block-scoped shadowing** — declare a same-named `const` in a nested block to safely shadow the outer one. [S1]
- **Declare-and-initialize** — always assign a `const` at declaration; deferred assignment is illegal. [S1]
## 📖 세부 내용 (Details)
**Const arrays** — It is a common practice to declare arrays using `const`: [S1]
```javascript
const cars = ["Saab", "Volvo", "BMW"];
```
**Cannot be Reassigned** — an array declared with `const` cannot be reassigned: [S1]
```javascript
const cars = ["Saab", "Volvo", "BMW"];
cars = ["Toyota", "Volvo", "Audi"]; // ERROR
```
**Elements Can be Reassigned** — you can change the elements of a constant array: [S1]
```javascript
// You can create a constant array:
const cars = ["Saab", "Volvo", "BMW"];
// You can change an element:
cars[0] = "Toyota";
// You can add an element:
cars.push("Audi");
```
**Assigned When Declared** — JavaScript `const` variables must be assigned a value when they are declared. This means an array declared with `const` must be initialized when it is declared. Declaring without initializing is a syntax error: [S1]
```javascript
const cars;
cars = ["Saab", "Volvo", "BMW"];
```
This is not how `var` works. With `var`, you can use the variable before it is declared: [S1]
```javascript
cars = ["Saab", "Volvo", "BMW"];
var cars;
```
**Const Block Scope** — a variable declared with `const` has block scope. A `const` declared in a block `{}` is not the same as a variable declared outside the block: [S1]
```javascript
const cars = ["Saab", "Volvo", "BMW"];
// Here cars[0] is "Saab"
{
const cars = ["Toyota", "Volvo", "BMW"];
// Here cars[0] is "Toyota"
}
// Here cars[0] is "Saab"
```
Redeclaring a `var` array with `var`, in another block, in the same program, is allowed and behaves differently (no block scope): [S1]
```javascript
var cars = ["Saab", "Volvo", "BMW"];
// Here cars[0] is "Saab"
{
var cars = ["Toyota", "Volvo", "BMW"];
// Here cars[0] is "Toyota"
}
// Here cars[0] is "Toyota"
```
**Redeclaring Arrays** — Redeclaring a `var` array is allowed anywhere in a program: [S1]
```javascript
var cars = ["Volvo", "BMW"]; // Allowed
var cars = ["Toyota", "BMW"]; // Allowed
cars = ["Volvo", "Saab"]; // Allowed
```
Redeclaring or reassigning an existing `var` or `const` array to `const`, in the same scope or block, is not allowed: [S1]
```javascript
var cars = ["Volvo", "BMW"]; // Allowed
const cars = ["Volvo", "BMW"]; // Not allowed
{
var cars = ["Volvo", "BMW"]; // Allowed
const cars = ["Volvo", "BMW"]; // Not allowed
}
```
Redeclaring or reassigning an existing `const` array, in the same scope or block, is not allowed: [S1]
```javascript
const cars = ["Volvo", "BMW"]; // Allowed
const cars = ["Volvo", "BMW"]; // Not allowed
var cars = ["Volvo", "BMW"]; // Not allowed
cars = ["Volvo", "BMW"]; // Not allowed
{
const cars = ["Volvo", "BMW"]; // Allowed
const cars = ["Volvo", "BMW"]; // Not allowed
var cars = ["Volvo", "BMW"]; // Not allowed
cars = ["Volvo", "BMW"]; // Not allowed
}
```
Redeclaring a `const` array, in another scope or block, is allowed: [S1]
```javascript
const cars = ["Volvo", "BMW"]; // Allowed
{
const cars = ["Volvo", "BMW"]; // Allowed
}
{
const cars = ["Volvo", "BMW"]; // Allowed
}
```
## 🛠️ 적용 사례 (Applied in summary)
The page's own snippets are the canonical applied examples — declaring a `cars` array with `const`, mutating its elements via index assignment and `push`, and demonstrating block-scope shadowing. No external project/commit applications found in the source.
## 💻 코드 패턴 (Code patterns)
Declare and mutate (allowed):
```javascript
const cars = ["Saab", "Volvo", "BMW"];
cars[0] = "Toyota";
cars.push("Audi");
```
Reassign (error):
```javascript
const cars = ["Saab", "Volvo", "BMW"];
cars = ["Toyota", "Volvo", "Audi"]; // ERROR
```
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
- **`const` vs `var` for arrays** — `const` has block scope, must be initialized at declaration, and cannot be reassigned or redeclared in the same scope; `var` lacks block scope, can be used before declaration, and can be freely redeclared. `const` is the recommended common practice. [S1]
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
No contradictions found in the source. The source notes that declaring arrays with `const` became common practice with ES2015 (ES6). [S1]
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.89
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[JavaScript Tutorial]]
- **관련 개념:** [[JavaScript Arrays]], [[JavaScript Array Iteration]], [[JavaScript Const]]
- **참조 맥락:** Referenced when deciding how to declare arrays and what mutability `const` guarantees.
## 📚 출처 (Sources)
- [S1] W3Schools — JavaScript Array Const — https://www.w3schools.com/js/js_array_const.asp
## 📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Array Const" page (Astra wiki-curation, P-Reinforce v3.1 format).