Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

eval 번역 (원문 저장소 변경 반영)#281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
1000peach wants to merge1 commit intojavascript-tutorial:masterfrom1000peach:Eval
Closed

Conversation

1000peach
Copy link
Contributor

원문 저장소 변경 반영하여 다시 번역했습니다. 리뷰 부탁드립니다.

Copy link
Member

@Violet-Bora-LeeViolet-Bora-Lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

몇가지 리뷰 남겨보았습니다.
요대로 하시구 커밋합쳐서 force push하시면
바로 머지진행할게요~

배포일정이 얼마 안남아서 잘 안읽히는 문장은 제가 대신 번역해보았어요.


```js run
let code = 'alert("Hello")';
eval(code); // Hello
```

A string of code may be long, contain line breaks, function declarations, variables and so on.
문자열 코드는 길거나 줄 바꿈, 함수 선언, 변수 등을 포함할 수 있습니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

길이가 긴 문자열이 코드가 될 수 있는데, 여기엔 줄 바꿈, 함수 선언, 변수 등이 포함될 수도 있습니다.


The result of`eval` is the result of the last statement.
`eval`은 마지막 구문의 결과를 반환합니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

마지막 구문의 결과가eval의 결과가 됩니다.

@@ -30,7 +30,7 @@ let value = eval('let i = 0; ++i');
alert(value); // 1
```

The eval'ed code is executed in the current lexical environment, so it can see outer variables:
eval로 둘러싼 코드는 현재 렉시컬 환경에서 실행되므로 외부 변수를 읽을 수 있습니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

eval로 둘러싼 코드는 현재 렉시컬 환경에서 실행되므로 외부 변수에 접근할 수 있습니다.

@@ -46,69 +46,69 @@ function f() {
f();
```

It can change outer variables as well:
외부 변수 변경도 가능합니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

외부 변수를 변경하는 것도 가능하죠.


```js untrusted refresh run
//reminder: 'use strict' is enabled in runnable examples by default
//참고: 'use strict'는 실행 예제에서 기본적으로 활성화 되어 있음

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

// 참고: 실행 가능한 모든 예시에 'use strict'가 적용되어있습니다.


**If eval'ed code doesn't use outer variables, please call`eval`as `window.eval(...)`:**
**eval로 감싼 코드를 외부 변수를 쓰지 않는다면`eval`대신 `window.eval(...)`을 호출하세요.**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
**eval로 감싼코드를 외부 변수를쓰지 않는다면`eval` 대신`window.eval(...)`을 호출하세요.**
**eval로 감싼코드에서 외부 변수를사용하지 않는다면,`eval` 대신`window.eval(...)`을 호출하세요.**

}
```

**If eval'ed code needs local variables, change`eval` to`new Function` and pass them as arguments:**
**eval로 감싼 코드가 지역 변수를 사용한다면`eval``new Function`으로 변경하고 eval로 감싼 코드는 인수로 전달하세요.**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
**eval로 감싼코드가 지역 변수를 사용한다면`eval``new Function`으로 변경하고 eval로 감싼 코드는 인수로 전달하세요.**
**eval로 감싼코드에서 지역 변수를 사용한다면,`eval`이 아닌`new Function`에 문자열로 된 코드를 전달하세요.**


```js run
let f = new Function('a', 'alert(a)');

f(5); // 5
```

The`new Function`construct is explained in the chapter<info:new-function>. It creates a function from a string, also in the global scope. So it can't see local variables. But it's so much clearer to pass them explicitly as arguments, like in the example above.
`new Function`문법은 챕터<info:new-function>에서 살펴봤는데, 이 문법은 인수로 받은 문자열을 기반으로 전역 스코프에 새로운 함수를 만들어줍니다. 따라서 `new Function`으로 만든 함수는 지역 변수에 접근할 수 없습니다. 하지만 위 예시처럼 `new Function`의 인수에 지역 변수를 명시해주면 훨씬 더 명확한 코드를 작성할 수 있습니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

new Function 문법(자세한 내용은 info:new-function챕터에서 살펴봄)은 인수로 받은 문자열을 기반으로 전역 스코프에 새로운 함수를 만들어줍니다. 따라서 지역 변수에 접근할 수 없죠. 하지만 위 예시에서처럼 코드 내부에서 지역 변수에 접근하지 말고 인수를 통해 값을 받는 게 훨씬 더 명확하다는 것을 알고 계시기 바랍니다.

`eval(code)`을 호출하면 문자열 형태의 `code`가 실행되는데 이때 마지막 구문의 결과가 반환됩니다.
- 모던 자바스크립트엔 eval을 대체할 수 있는 문법이 많기 때문에, 모던 자바스크립트를 사용하는 코드에선 eval을 잘 사용하지 않습니다.
- eval을 이용해 만든 코드는 외부 지역 변수에 접근할 수 있는데, 이는 좋지 않은 방법입니다.
- 전역 스코프에서 사용된 `eval`은 `window.eval(code)`을 이용해 대체할 수 있습니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

전역 스코프에서eval을 사용하지 말고,window.eval(code)을 이용하세요.

-모던 자바스크립트엔 eval을 대체할 수 있는 문법이 많기 때문에, 모던 자바스크립트를 사용하는 코드에선 eval을 잘 사용하지 않습니다.
-eval을 이용해 만든 코드는 외부 지역 변수에 접근할 수 있는데, 이는 좋지 않은 방법입니다.
-전역 스코프에서 사용된`eval``window.eval(code)`을 이용해 대체할 수 있습니다.
-외부 스코프에 있는 데이터(변수)가 필요한 코드를 작성 중이라면`new Function`에 해당 코드를 인수로 전달해 사용할 수도 있습니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

외부 스코프에 있는 데이터가 필요하다면new Function의 인수에 코드를 전달해 사용하시면 됩니다.

@javascript-translate-bot

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@Violet-Bora-LeeViolet-Bora-LeeViolet-Bora-Lee requested changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@1000peach@javascript-translate-bot@Violet-Bora-Lee

[8]ページ先頭

©2009-2025 Movatter.jp