이전 재구성 작업에서 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.
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-array-const | JavaScript Array Const | Frontend | draft | conceptual |
|
B | 0.89 | 2026-06-23 | 2026-06-23 |
|
|
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)
constis common practice for arrays — ES2015 (ES6) made declaring arrays withconststandard practice. [S1]- A const array cannot be reassigned — assigning a new array to the same
constname is an ERROR. [S1] - Const array elements CAN change — you can change, add (
push), or remove elements of aconstarray. [S1] - Const must be assigned when declared — declaring without assignment is a syntax error. [S1]
- Const has block scope — a
constdeclared inside a block is not the same variable as one outside the block. [S1] - Const cannot be redeclared — you cannot redeclare or reassign a
constin the same scope, but you can declare a newconstwith the same name in a different block scope. [S1]
🧩 추출된 패턴 (Extracted patterns)
- Mutate-not-rebind pattern — use
constfor arrays you will mutate in place (cars[0] = ...,cars.push(...)) but never reassign. [S1] - Block-scoped shadowing — declare a same-named
constin a nested block to safely shadow the outer one. [S1] - Declare-and-initialize — always assign a
constat declaration; deferred assignment is illegal. [S1]
📖 세부 내용 (Details)
Const arrays — It is a common practice to declare arrays using const: [S1]
const cars = ["Saab", "Volvo", "BMW"];
Cannot be Reassigned — an array declared with const cannot be reassigned: [S1]
const cars = ["Saab", "Volvo", "BMW"];
cars = ["Toyota", "Volvo", "Audi"]; // ERROR
Elements Can be Reassigned — you can change the elements of a constant array: [S1]
// 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]
const cars;
cars = ["Saab", "Volvo", "BMW"];
This is not how var works. With var, you can use the variable before it is declared: [S1]
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]
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]
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]
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]
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]
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]
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):
const cars = ["Saab", "Volvo", "BMW"];
cars[0] = "Toyota";
cars.push("Audi");
Reassign (error):
const cars = ["Saab", "Volvo", "BMW"];
cars = ["Toyota", "Volvo", "Audi"]; // ERROR
⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
constvsvarfor arrays —consthas block scope, must be initialized at declaration, and cannot be reassigned or redeclared in the same scope;varlacks block scope, can be used before declaration, and can be freely redeclared.constis 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
constguarantees.
📚 출처 (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).