You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/04-object-methods/article.md
-31Lines changed: 0 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,19 +32,11 @@ user.sayHi = function() {
32
32
user.sayHi(); // 안녕하세요!
33
33
```
34
34
35
-
<<<<<<< HEAD
36
35
함수 표현식으로 함수를 만들고, 객체 프로퍼티 `user.sayHi`에 함수를 할당해 주었습니다.
37
36
38
37
이제 객체에 할당된 함수를 호출하면 user가 인사를 해줍니다.
39
38
40
39
이렇게 객체 프로퍼티에 할당된 함수를 *메서드(method)* 라고 부릅니다.
41
-
=======
42
-
Here we've just used a Function Expression to create a function and assign it to the property `user.sayHi` of the object.
43
-
44
-
Then we can call it as `user.sayHi()`. The user can now speak!
45
-
46
-
A function that is a property of an object is called its *method*.
47
-
>>>>>>> upstream/master
48
40
49
41
위 예시에선 `user`에 할당된 `sayHi`가 메서드이죠.
50
42
@@ -58,13 +50,8 @@ let user = {
58
50
*!*
59
51
// 함수 선언
60
52
functionsayHi() {
61
-
<<<<<<<HEAD
62
53
alert("안녕하세요!");
63
54
};
64
-
=======
65
-
alert("Hello!");
66
-
}
67
-
>>>>>>> upstream/master
68
55
69
56
// 선언된 함수를 메서드로 등록
70
57
user.sayHi= sayHi;
@@ -94,11 +81,7 @@ user = {
94
81
// 단축 구문을 사용하니 더 깔끔해 보이네요.
95
82
user = {
96
83
*!*
97
-
<<<<<<<HEAD
98
84
sayHi() { // "sayHi: function()"과 동일합니다.
99
-
=======
100
-
sayHi() { // same as "sayHi: function(){...}"
101
-
>>>>>>> upstream/master
102
85
*/!*
103
86
alert("Hello");
104
87
}
@@ -107,11 +90,7 @@ user = {
107
90
108
91
위처럼 `function`을 생략해도 메서드를 정의할 수 있습니다.
109
92
110
-
<<<<<<< HEAD
111
93
일반적인 방법과 단축 구문을 사용한 방법이 완전히 동일하진 않습니다. 객체 상속과 관련된 미묘한 차이가 존재하는데 지금으로선 이 차이가 중요하지 않기 때문에 넘어가도록 하겠습니다.
112
-
=======
113
-
To tell the truth, the notations are not fully identical. There are subtle differences related to object inheritance (tobecoveredlater), but for now they do not matter. In almost all cases, the shorter syntax is preferred.
0 commit comments