aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/referenceerror/index.html
blob: ed5fee8c480bf1238fc121760431dcba6ab23ade (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
title: ReferenceError
slug: Web/JavaScript/Reference/Global_Objects/ReferenceError
translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError
---
<div>{{JSRef}}</div>

<div>
<p><code><strong>ReferenceError</strong></code> 객체는 존재하지 않는 변수를 참조했을 때 발생하는 에러를 나타냅니다.</p>
</div>

<h2 id="문법">문법</h2>

<pre class="syntaxbox"><code>new ReferenceError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</code></pre>

<h3 id="파라미터">파라미터</h3>

<dl>
 <dt><code>message</code></dt>
 <dd>선택사항. 에러에 대한 설명문</dd>
 <dt><code>fileName</code> {{non-standard_inline}}</dt>
 <dd>선택사항. 예외가 발생한 코드를 포함하는 파일의 이름</dd>
 <dt><code>lineNumber</code> {{non-standard_inline}}</dt>
 <dd>선택사항. 예외가 발생한 코드의 줄 번호</dd>
</dl>

<h2 id="설명">설명</h2>

<p><strong><code>ReferenceError</code></strong>는 선언된 적이 없는 변수를 참조하려고 할 때 발생합니다.</p>

<h2 id="프로퍼티">프로퍼티</h2>

<dl>
 <dt>{{jsxref("ReferenceError.prototype")}}</dt>
 <dd>ReferenceError 객체에 프로퍼티를 추가할 수 있습니다.</dd>
</dl>

<h2 id="메서드">메서드</h2>

<p>전역 ReferenceError는 메서드를 가지고 있지 않습니다. 그러나 상속 관계에서 프로토타입 체인을 통해 일부 메서드를 가질 수 있습니다.</p>

<h2 id="ReferenceError_인스턴스"><code>ReferenceError</code> 인스턴스</h2>

<h3 id="프로퍼티_2">프로퍼티</h3>

<div>{{page('/ko-KR/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype', 'Properties')}}</div>

<h3 id="메서드_2">메서드</h3>

<div>{{page('/ko-KR/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype', 'Methods')}}</div>

<h2 id="예제">예제</h2>

<h3 id="ReferenceError_처리하기"><code>ReferenceError</code> 처리하기</h3>

<pre class="brush: js">try {
  var a = undefinedVariable;
} catch (e) {
  console.log(e instanceof ReferenceError); // true
  console.log(e.message);                   // "undefinedVariable is not defined"
  console.log(e.name);                      // "ReferenceError"
  console.log(e.fileName);                  // "Scratchpad/1"
  console.log(e.lineNumber);                // 2
  console.log(e.columnNumber);              // 6
  console.log(e.stack);                     // "@Scratchpad/2:2:7\n"
}
</pre>

<h3 id="ReferenceError_생성하기"><code>ReferenceError</code> 생성하기</h3>

<pre class="brush: js">try {
  throw new ReferenceError('Hello', 'someFile.js', 10);
} catch (e) {
  console.log(e instanceof ReferenceError); // true
  console.log(e.message);                   // "Hello"
  console.log(e.name);                      // "ReferenceError"
  console.log(e.fileName);                  // "someFile.js"
  console.log(e.lineNumber);                // 10
  console.log(e.columnNumber);              // 0
  console.log(e.stack);                     // "@Scratchpad/2:2:9\n"
}
</pre>

<h2 id="명세">명세</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES3')}}</td>
   <td>{{Spec2('ES3')}}</td>
   <td>Initial definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.11.6.3', 'ReferenceError')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-native-error-types-used-in-this-standard-referenceerror', 'ReferenceError')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard-referenceerror', 'ReferenceError')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="브라우저_호환성">브라우저 호환성</h2>

<div>
<div class="hidden">이 페이지의 호환성 테이블은 구조화된 데이터로부터 생성됩니다. 해당 데이터를 개선하고 싶다면 <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>을 체크아웃하고 저희에게 풀 리퀘스트를 보내주십시오.</div>

<p>{{Compat("javascript.builtins.ReferenceError")}}</p>
</div>

<h2 id="참고">참고</h2>

<ul>
 <li>{{jsxref("Error")}}</li>
 <li>{{jsxref("ReferenceError.prototype")}}</li>
</ul>