--- 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).