From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../reference/errors/undeclared_var/index.html | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 files/ko/web/javascript/reference/errors/undeclared_var/index.html (limited to 'files/ko/web/javascript/reference/errors/undeclared_var') diff --git a/files/ko/web/javascript/reference/errors/undeclared_var/index.html b/files/ko/web/javascript/reference/errors/undeclared_var/index.html new file mode 100644 index 0000000000..688c92473d --- /dev/null +++ b/files/ko/web/javascript/reference/errors/undeclared_var/index.html @@ -0,0 +1,62 @@ +--- +title: 'ReferenceError: assignment to undeclared variable "x"' +slug: Web/JavaScript/Reference/Errors/Undeclared_var +translation_of: Web/JavaScript/Reference/Errors/Undeclared_var +--- +
{{jsSidebar("Errors")}}
+ +

메시지

+ +
ReferenceError: assignment to undeclared variable "x" (Firefox)
+ReferenceError: "x" is not defined (Chrome)
+ReferenceError: Variable undefined in strict mode (Edge)
+
+ +

에러 형식

+ +

엄격 모드(strict mode)에서만 발생하는 {{jsxref("ReferenceError")}} 경고.

+ +

무엇이 잘못되었을까?

+ +

선언되지 않은 변수로 값은 할당되었습니다. var 키워드가 없이 할당이 된 것입니다. 선언된 변수와 선언되지 않은 변수 사이에는 차이가 있는데, 이는 예상치 못한 결과를 가져오며, 때문에 JavaScript 엄격모드에서는 에러를 발생시키고 있습니다.

+ +

선언된 변수와 선언되지 않은 변수에 대하여 기억해야 할 세 가지:

+ + + +

더 많은 설명과 예제를 필요로 한다면 이 var 참조문서 페이지를 보세요.

+ +

선언되지 않은 변수 할당에 대한 에러는 엄격 모드(strict mode code)에서만 발생합니다. 비-엄격 코드에서는 조용히 묵인됩니다.

+ +

+ +

허용되지 않는 경우

+ +

이런 경우에는, 변수 "bar"는 선언되지 않은 변수가 됩니다.

+ +
function foo() {
+  "use strict";
+  bar = true;
+}
+foo(); // ReferenceError: assignment to undeclared variable bar
+
+ +

허용되는 경우

+ +

"bar" 를 선언된 변수로 만들기 위해서, var 키워드를 변수명 앞에 붙여줍니다.

+ +
function foo() {
+  "use strict";
+  var bar = true;
+}
+foo();
+ +

참조

+ + -- cgit v1.2.3-54-g00ecf