--- id: javascript-object-methods title: "JavaScript Object Methods" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["JS object methods", "object method", "this keyword", "method call parentheses", "fullName", "function as property"] 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", "methods", "this"] raw_sources: ["https://www.w3schools.com/js/js_object_methods.asp"] applied_in: [] github_commit: "" --- # [[JavaScript Object Methods]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Methods are functions stored as object property values; call them with parentheses, and inside them `this` refers to the owning object. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Methods are actions on objects** β€” they are functions stored as property values. [S1] - **`this` is the object** β€” in an object method, `this` refers to the object that owns the method. [S1] - **Parentheses execute the method** β€” `person.fullName()` runs the function; `person.fullName` returns the function definition. [S1] - **Add methods by assignment** β€” assign a function to a property to add a method. [S1] - **Built-in methods compose** β€” a method can call JavaScript built-ins such as `toUpperCase()`. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **`this`-based accessor method** β€” `fullName: function() { return this.firstName + " " + this.lastName; }` combines own properties. [S1] - **Late method attachment** β€” `person.name = function () { ... }` adds behavior to an existing object. [S1] - **Method + built-in chaining** β€” wrap the result and call a built-in: `(this.firstName + " " + this.lastName).toUpperCase()`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **What are Object Methods?** Methods are actions that can be performed on objects. Methods are functions stored as property values. [S1] ```javascript const person = { firstName: "John", lastName: "Doe", age: 50, fullName: function() { return this.firstName + " " + this.lastName; } }; ``` | Property | Value | | --- | --- | | firstName | John | | lastName | Doe | | age | 50 | | **fullName** | **function() { return this.firstName + " " + this.lastName; }** | **The this Keyword** In an object method, `this` refers to the object. [S1] ```javascript const person = { firstName: "John", lastName: "Doe", id: 5566, getId: function() { return this.id; } }; let number = person.getId(); ``` Here `this` refers to the person object; `this.id` means the `id` property of the person object. [S1] ```javascript const person = { firstName: "John", lastName: "Doe", age: 50, fullName: function() { return this.firstName + " " + this.lastName; } }; ``` Here `this` refers to the person object; `this.firstName` means the `firstName` property and `this.lastName` the `lastName` property. [S1] **Accessing Object Methods** To call an object method, add parentheses `()`. Without parentheses you get the function itself. Syntax: [S1] ```javascript objectName.methodName() ``` If you call a method with parentheses, it executes as a function: [S1] ```javascript name = person.fullName(); ``` If you call a method without parentheses, it returns the function definition: [S1] ```javascript name = person.fullName; ``` **Adding a Method to an Object** You can add a method to an object by assigning a function to a property: [S1] ```javascript // Assign person.name to a function person.name = function () { return this.firstName + " " + this.lastName; }; ``` Here `person.name` is a property with a function assigned to it. [S1] **Adding a JavaScript Method** This example uses the JavaScript `toUpperCase()` method to convert a text to uppercase: [S1] ```javascript person.name = function () { return (this.firstName + " " + this.lastName).toUpperCase(); }; ``` **Summary** Methods are functions stored as object properties; call a method with parentheses (`person.fullName()`); in methods, `this` refers to the object; you can add methods to objects by assigning a function to a property. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own snippets are the canonical applied examples β€” the `fullName`/`getId` methods using `this`, the parentheses-vs-no-parentheses call comparison, and late attachment of `person.name`. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Method using `this`: ```javascript fullName: function() { return this.firstName + " " + this.lastName; } ``` Add a method by assignment: ```javascript person.name = function () { return this.firstName + " " + this.lastName; }; ``` Compose with a built-in: ```javascript person.name = function () { return (this.firstName + " " + this.lastName).toUpperCase(); }; ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (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 Properties]], [[JavaScript Object this]] - **μ°Έμ‘° λ§₯락:** Referenced whenever attaching behavior to objects and reasoning about `this` inside methods. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” JavaScript Object Methods β€” https://www.w3schools.com/js/js_object_methods.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Object Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).