--- id: javascript-undefined title: "JavaScript undefined" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["undefined", "JS undefined", "undefined value", "typeof undefined", "unassigned variable"] 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", "undefined", "data-types"] raw_sources: ["https://www.w3schools.com/js/js_undefined.asp"] applied_in: [] github_commit: "" --- # [[JavaScript undefined]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `undefined` is the value a variable automatically receives when it has been declared but no value has been assigned β€” a distinct JavaScript value, separate from `null` and from an empty string. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Declared-but-unassigned** β€” A variable declared without a value automatically has the value `undefined`. [S1] - **`typeof` reports it** β€” You can use `typeof` to check if a variable is undefined. [S1] - **Empty string is not undefined** β€” An empty string has a value and a type; it is not the same as `undefined`. [S1] - **Missing object property** β€” Accessing a non-existing object property returns `undefined`. [S1] - **No-return function** β€” A function without a return value returns `undefined`. [S1] - **Emptying an object** β€” Objects can be emptied by setting the value to `undefined` (or alternatively to `null`). [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Detect unset state with `typeof`** β€” Use `typeof x` to distinguish a declared-but-unassigned variable from one holding a value. [S1] - **`undefined` as a default signal** β€” Missing object properties and value-less functions both surface as `undefined`, making it the de facto "absence of value" marker. [S1] - **Empty vs. undefined** β€” An empty string `""` is a real value with type `"string"`, distinct from `undefined`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Undefined Variables** A variable declared without a value will automatically have the value `undefined`. [S1] ```javascript let car; document.getElementById("demo").innerHTML = car; ``` **The Type of undefined** You can use `typeof` to check if a variable is undefined. [S1] ```javascript let car; document.getElementById("demo").innerHTML = typeof car; ``` **Empty Values** An empty string has a value and a type. It is not the same as `undefined`. [S1] ```javascript let text = ""; document.getElementById("demo").innerHTML = text + "
" + typeof text; ``` **Objects and undefined** Accessing a non-existing object property returns `undefined`. [S1] ```javascript const person = {firstName:"John", lastName:"Doe"}; document.getElementById("demo").innerHTML = person.age; ``` **Functions and undefined** A function without a return value returns `undefined`. [S1] ```javascript function myFunction() { let x = 5; } document.getElementById("demo").innerHTML = myFunction(); ``` **You Can Empty an Object** Objects can be emptied by setting the value to `undefined`. Objects can also be emptied by setting the value to `null`. [S1] ```javascript const person = {firstName:"John", lastName:"Doe"}; person = undefined; ``` **Note** "`undefined` is a JavaScript value. It means that a variable has been declared, but no value has been assigned." [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own snippets are the canonical applied examples β€” reading an unassigned `car`, checking `typeof car`, and accessing the missing `person.age`. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Check whether a variable is undefined (language: JavaScript): ```javascript let car; document.getElementById("demo").innerHTML = typeof car; ``` Detect a missing object property: ```javascript const person = {firstName:"John", lastName:"Doe"}; document.getElementById("demo").innerHTML = person.age; ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (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 NaN]], [[JavaScript Type Conversion]], [[JavaScript Object Types Note]], [[JavaScript Introduction]] - **μ°Έμ‘° λ§₯락:** Referenced whenever checking for missing values, optional object properties, or void function returns. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript undefined β€” https://www.w3schools.com/js/js_undefined.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript undefined" page (Astra wiki-curation, P-Reinforce v3.1 format).