docs(10_Wiki): W3Schools 위키화 — HTML/CSS/JavaScript(core)
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>
This commit is contained in:
@@ -0,0 +1,191 @@
|
||||
---
|
||||
id: javascript-object-properties
|
||||
title: "JavaScript Object Properties"
|
||||
category: "Frontend"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["JS object properties", "dot notation", "bracket notation", "delete property", "in operator", "nested objects", "key value pairs"]
|
||||
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", "objects", "properties", "dot-notation"]
|
||||
raw_sources: ["https://www.w3schools.com/js/js_object_properties.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[JavaScript Object Properties]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An object is a collection of `key:value` properties that can be changed, added, and deleted — accessed by dot notation, bracket notation, or an expression. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Properties are key:value pairs** — a JavaScript object is a collection of properties that can be changed, added, and deleted. [S1]
|
||||
- **Three access ways** — dot notation, bracket notation, and expression (a name stored in a variable). [S1]
|
||||
- **Dot notation preferred** — it is generally preferred for readability and simplicity. [S1]
|
||||
- **Bracket notation when needed** — required when the property name is in a variable or is not a valid identifier (e.g. `"last-name"`). [S1]
|
||||
- **`delete` removes value and property** — after deletion, accessing the property returns `undefined`. [S1]
|
||||
- **`in` operator** — checks whether a property exists in an object. [S1]
|
||||
- **Nested objects** — property values can be other objects, reachable by chaining dot/bracket notation. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Dynamic property access** — `person[myVariable]` resolves a property whose name is held in a variable. [S1]
|
||||
- **Add-by-assignment** — assigning to a non-existent property (`person.nationality = "English"`) creates it. [S1]
|
||||
- **Existence check before use** — `("firstName" in person)` guards access to optional properties. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
**Properties are key:value Pairs**
|
||||
A JavaScript object is a collection of properties. Properties can be changed, added, and deleted. [S1]
|
||||
|
||||
**Accessing JavaScript Properties**
|
||||
You can access object properties by dot notation, bracket notation, or expression: [S1]
|
||||
```javascript
|
||||
// objectName.property
|
||||
let age = person.age;
|
||||
|
||||
// objectName["property"]
|
||||
let age = person["age"];
|
||||
|
||||
// objectName[expression]
|
||||
let age = person[x];
|
||||
```
|
||||
|
||||
**Dot Notation** — `objectName.propertyName`: [S1]
|
||||
```javascript
|
||||
person.firstname + " is " + person.age;
|
||||
```
|
||||
|
||||
**Bracket Notation** — `objectName["propertyName"]`: [S1]
|
||||
```javascript
|
||||
person["firstname"] + " is " + person["age"];
|
||||
```
|
||||
In general, dot notation is preferred for readability and simplicity. Bracket notation is necessary in some cases: when the property name is stored in a variable (`person[myVariable]`), or when the property name is not a valid identifier (`person["last-name"]`). Bracket notation is useful when the property name is stored in a variable: [S1]
|
||||
```javascript
|
||||
let n1 = "firstName";
|
||||
let n2 = "lastName";
|
||||
|
||||
let name = person[n2] + " " + person[n2];
|
||||
```
|
||||
|
||||
**Changing Properties** — you can change the value of a property: [S1]
|
||||
```javascript
|
||||
person.age = 10;
|
||||
```
|
||||
|
||||
**Adding New Properties** — add a new property by simply giving it a value: [S1]
|
||||
```javascript
|
||||
person.nationality = "English";
|
||||
```
|
||||
|
||||
**Deleting Properties** — the `delete` keyword deletes a property from an object: [S1]
|
||||
```javascript
|
||||
const person = {
|
||||
firstName: "John",
|
||||
lastName: "Doe",
|
||||
age: 50,
|
||||
};
|
||||
|
||||
delete person.age;
|
||||
```
|
||||
```javascript
|
||||
const person = {
|
||||
firstName: "John",
|
||||
lastName: "Doe",
|
||||
age: 50,
|
||||
};
|
||||
|
||||
delete person["age"];
|
||||
```
|
||||
The `delete` keyword deletes both the value and the property. After deleting, the property is removed; accessing it will return `undefined`. [S1]
|
||||
|
||||
**Check if a Property Exists** — use the `in` operator: [S1]
|
||||
```javascript
|
||||
const person = {
|
||||
firstName: "John",
|
||||
lastName: "Doe"
|
||||
};
|
||||
|
||||
let result = ("firstName" in person);
|
||||
```
|
||||
|
||||
**Nested Objects** — property values in an object can be other objects: [S1]
|
||||
```javascript
|
||||
myObj = {
|
||||
name:"John",
|
||||
age:30,
|
||||
myCars: {
|
||||
car1:"Ford",
|
||||
car2:"BMW",
|
||||
car3:"Fiat"
|
||||
}
|
||||
}
|
||||
```
|
||||
You can access nested objects using dot notation or bracket notation: [S1]
|
||||
```javascript
|
||||
myObj.myCars.car2;
|
||||
```
|
||||
```javascript
|
||||
myObj.myCars["car2"];
|
||||
```
|
||||
```javascript
|
||||
myObj["myCars"]["car2"];
|
||||
```
|
||||
```javascript
|
||||
let p1 = "myCars";
|
||||
let p2 = "car2";
|
||||
myObj[p1][p2];
|
||||
```
|
||||
|
||||
**Summary**
|
||||
Object properties are key:value pairs; access properties with dot notation or bracket notation; add, change, and delete properties using assignment and `delete`; use the `in` operator to check if a property exists. [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
| Access style | Use when | Note |
|
||||
| --- | --- | --- |
|
||||
| Dot notation `obj.prop` | Default | Preferred for readability and simplicity [S1] |
|
||||
| Bracket notation `obj["prop"]` | Name in a variable, or not a valid identifier | e.g. `obj[myVar]`, `obj["last-name"]` [S1] |
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
The page's own snippets are the canonical applied examples — accessing `person.firstname`/`person["firstname"]`, dynamic access via variables, `delete person.age`, the `in` check, and nested `myObj.myCars.car2` access. No external project/commit applications found in the source.
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Dynamic property access via a variable:
|
||||
```javascript
|
||||
let n2 = "lastName";
|
||||
let name = person[n2];
|
||||
```
|
||||
Add then delete a property:
|
||||
```javascript
|
||||
person.nationality = "English";
|
||||
delete person.age;
|
||||
```
|
||||
Existence check:
|
||||
```javascript
|
||||
let result = ("firstName" in person);
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (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)
|
||||
- **상위/루트:** [[JavaScript Tutorial]]
|
||||
- **관련 개념:** [[JavaScript Objects]], [[JavaScript Object Methods]], [[JavaScript Object Display]]
|
||||
- **참조 맥락:** Referenced whenever reading, writing, adding, or removing data on an object.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — JavaScript Object Properties — https://www.w3schools.com/js/js_object_properties.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Object Properties" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user