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,164 @@
|
||||
---
|
||||
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).
|
||||
Reference in New Issue
Block a user