--- id: javascript-object-this title: "JavaScript Object this" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["JS this keyword", "this in objects", "this alone", "this in a function", "global object", "window object"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.88 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["javascript", "js", "web", "frontend", "w3schools", "objects", "this", "context"] raw_sources: ["https://www.w3schools.com/js/js_object_this.asp"] applied_in: [] github_commit: "" --- # [[JavaScript Object this]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `this` refers to the object calling a method β€” inside an object method it is that object, but used alone or in a regular function it refers to the global object. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`this` refers to an object** β€” it is used to access the object that is calling a method. [S1] - **In an object method, `this` is the object** β€” it lets the method access the object's properties. [S1] - **Reusable methods** β€” `this` makes it possible to use the same method with different objects. [S1] - **`this` alone is the global object** β€” in a browser that is the `window` object; in strict mode it is `undefined`. [S1] - **In a regular function, `this` is the global object** too. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Shared-method pattern** β€” define the same `hello()` method on multiple objects so each resolves `this.name` to its own value. [S1] - **Property access via `this`** β€” `this.firstName` / `this.lastName` reach own properties from within a method. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **this in Objects** The `this` keyword refers to an object. In JavaScript, `this` is used to access the object that is calling a method. [S1] **this in an Object Method** When used inside an object method, `this` refers to the object. [S1] ```javascript const person = { firstName: "John", lastName: "Doe", age: 50, fullName: function() { return this.firstName + " " + this.lastName; } }; ``` Here `this.firstName` refers to the `firstName` property of the person object, and `this.lastName` refers to the `lastName` property. [S1] **Why Use this?** The `this` keyword makes it possible to use the same method with different objects. [S1] ```javascript const person1 = { name: "John", hello: function() { return "Hello " + this.name; } }; const person2 = { name: "Anna", hello: function() { return "Hello " + this.name; } }; document.getElementById("demo").innerHTML = person1.hello(); ``` **this Alone** When used alone, `this` refers to the global object. In a browser, the global object is the `window` object. In strict mode, `this` is `undefined` when used alone. [S1] ```javascript let x = this; document.getElementById("demo").innerHTML = x; ``` **this in a Function** In a regular function, `this` also refers to the global object. [S1] ```javascript function myFunction() { return this; } document.getElementById("demo").innerHTML = myFunction(); ``` **Summary** In an object method, `this` refers to the object; `this` lets methods access object properties; used alone, `this` refers to the global object. [S1] ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) | Context | What `this` refers to | | --- | --- | | Inside an object method | The owning object [S1] | | Used alone | The global object (`window` in a browser); `undefined` in strict mode [S1] | | Inside a regular function | The global object [S1] | ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own snippets are the canonical applied examples β€” `person.fullName` using `this`, the shared `hello()` method across `person1`/`person2`, and `this` returned alone and from a regular function. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Same method, different objects: ```javascript const person1 = { name: "John", hello: function() { return "Hello " + this.name; } }; const person2 = { name: "Anna", hello: function() { return "Hello " + this.name; } }; ``` `this` alone resolves to the global object: ```javascript let x = this; ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. The page notes a mode distinction: `this` used alone is the global object normally, but `undefined` in strict mode. [S1] ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.88 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[JavaScript Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[JavaScript Object Methods]], [[JavaScript Objects]], [[JavaScript Arrow Functions]] - **μ°Έμ‘° λ§₯락:** Referenced whenever reasoning about method context, and contrasted with arrow functions, which do not bind their own `this`. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript Object this β€” https://www.w3schools.com/js/js_object_this.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Object this" page (Astra wiki-curation, P-Reinforce v3.1 format).