Skip to content

Commit 417a512

Browse files
HyunsangHanViolet-Bora-Lee
authored andcommitted
[메서드와 'this'] 과제 번역
- 4-object-property-this의 solution 외 잔여 과제 및 해답을 모두 번역했음
1 parent 1ae50fe commit 417a512

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

1-js/04-object-basics/04-object-methods/2-check-syntax/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let user = {
1111
(user.go)() // error!
1212
```
1313

14-
The error message in most browsers does not give us much of a clue about what went wrong.
14+
브라우저에서 출력되는 에러 메시지만 봐서는 무엇이 잘못되었는지 파악하기 어려울 겁니다.
1515

1616
**에러는 `user = {...}`뒤에 세미콜론이 없어서 발생했습니다.**
1717

@@ -21,7 +21,7 @@ The error message in most browsers does not give us much of a clue about what we
2121
let user = { go:... }(user.go)()
2222
```
2323

24-
Then we can also see that such a joint expression is syntactically a call of the object `{ go: ... }` as a function with the argument `(user.go)`. And that also happens on the same line with `let user`, so the `user` object has not yet even been defined, hence the error.
24+
이렇게 두 표현식이 합쳐지면서 인수가 `(user.go)`인 객체 형태의 함수를 호출한 것처럼 보입니다. 게다가 객체 `user`가 정의되지 않은 상태에서 같은 줄에 `let user`를 사용했기 때문에 에러가 발생합니다.
2525

2626
`user = {...}`뒤에 세미콜론을 붙여서 에러를 해결해봅시다.
2727

1-js/04-object-basics/04-object-methods/4-object-property-this/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 5
22

33
---
44

5-
# Using "this" in object literal
5+
# 객체 리터럴에서 'this' 사용하기
66

7-
Here the function `makeUser` returns an object.
7+
함수 `makeUser`는 객체를 반환합니다.
88

9-
What is the result of accessing its `ref`? Why?
9+
이 객체의 `ref`에 접근하면 어떤 결과가 발생하고, 그 이유는 뭘까요?
1010

1111
```js
1212
function makeUser() {
@@ -18,6 +18,6 @@ function makeUser() {
1818

1919
let user = makeUser();
2020

21-
alert( user.ref.name ); // What's the result?
21+
alert( user.ref.name ); // 결과가 어떻게 될까요?
2222
```
2323

1-js/04-object-basics/04-object-methods/7-calculator/task.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ importance: 5
22

33
---
44

5-
# Create a calculator
5+
# 계산기 만들기
66

7-
Create an object `calculator` with three methods:
7+
아래 3가지 메서드를 가진 `calculator`라는 객체를 만들어보세요.
88

9-
- `read()` prompts for two values and saves them as object properties.
10-
- `sum()` returns the sum of saved values.
11-
- `mul()` multiplies saved values and returns the result.
9+
- `read()`는 프롬프트 창에서 두 값을 보여주고 객체의 프로퍼티로 저장합니다.
10+
- `sum()`은 저장된 두 값의 합을 반환합니다.
11+
- `mul()`은 저장된 두 값의 곱을 반환합니다.
1212

1313
```js
1414
let calculator = {
15-
// ... your code ...
15+
// ... 여기에 답안 작성 ...
1616
};
1717

1818
calculator.read();

1-js/04-object-basics/04-object-methods/8-chain-calls/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The solution is to return the object itself from every call.
1+
메서드를 호출할 때마다 객체 자신을 반환하게 하면 됩니다.
22

33
```js run demo
44
let ladder = {
@@ -26,7 +26,7 @@ let ladder = {
2626
ladder.up().up().down().up().down().showStep(); // 1
2727
```
2828

29-
We also can write a single call per line. For long chains it's more readable:
29+
메서드 호출 하나씩 한 줄에 작성할 수도 있습니다. 체이닝이 길어질 경우 이렇게 작성하면 가독성이 좋아집니다.
3030

3131
```js
3232
ladder

1-js/04-object-basics/04-object-methods/8-chain-calls/task.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 2
22

33
---
44

5-
# Chaining
5+
# 체이닝
66

7-
There's a `ladder` object that allows to go up and down:
7+
올라가기와 내려가기 메서드를 제공하는 객체 `ladder`가 있다고 합시다.
88

99
```js
1010
let ladder = {
@@ -15,13 +15,13 @@ let ladder = {
1515
down() {
1616
this.step--;
1717
},
18-
showStep: function() { // shows the current step
18+
showStep: function() { // 사다리에서 몇 번째 단에 올라와 있는지 보여줌
1919
alert( this.step );
2020
}
2121
};
2222
```
2323

24-
Now, if we need to make several calls in sequence, can do it like this:
24+
만일 메서드를 연이어 호출하고자 한다면 아래와 같이 코드를 작성할 수 있습니다.
2525

2626
```js
2727
ladder.up();
@@ -30,10 +30,10 @@ ladder.down();
3030
ladder.showStep(); // 1
3131
```
3232

33-
Modify the code of `up`, `down` and `showStep` to make the calls chainable, like this:
33+
아래와 같이 메서드 호출 체이닝이 가능하도록 `up`, `down`, `showStep`을 수정해보세요.
3434

3535
```js
3636
ladder.up().up().down().showStep(); // 1
3737
```
3838

39-
Such approach is widely used across JavaScript libraries.
39+
이러한 방식은 자바스크립트 라이브러리에서 널리 사용됩니다.

0 commit comments

Comments
 (0)