Skip to content

Commit 691211e

Browse files
fix error on 'new 연산자와 생성자 함수'
1 parent 669c453 commit 691211e

File tree

1 file changed

+3
-3
lines changed
  • 1-js/04-object-basics/06-constructor-new

1 file changed

+3
-3
lines changed

1-js/04-object-basics/06-constructor-new/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ function User(name) {
122122
this.name = name;
123123
}
124124

125-
let john = User("보라"); // 'new User'를 쓴 것처럼 바꿔줍니다.
126-
alert(john.name); // 보라
125+
let bora = User("보라"); // 'new User'를 쓴 것처럼 바꿔줍니다.
126+
alert(bora.name); // 보라
127127
```
128128

129129
라이브러리를 분석하다 보면 위와 같은 방식이 쓰인 걸 발견할 때가 있을 겁니다. 이런 방식을 사용하면 `new`를 붙여 함수를 호출하든 아니든 코드가 동일하게 동작하기 때문에, 좀 더 유연하게 코드를 작성할 수 있습니다.
@@ -201,7 +201,7 @@ function User(name) {
201201
*!*
202202
let bora = new User("이보라");
203203

204-
john.sayHi(); // 내 이름은 이보라입니다.
204+
bora.sayHi(); // 내 이름은 이보라입니다.
205205
*/!*
206206

207207
/*

0 commit comments

Comments
 (0)