diff options
author | alattalatta <urty5656@gmail.com> | 2021-06-23 16:51:19 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 16:51:19 +0900 |
commit | aecf6d3acaa1fac94d24c53e1dda4cd136105df0 (patch) | |
tree | 65ffa86e3949b2fec27af88b9c975fc417354ce9 /files/ko | |
parent | 2182002b8988fd49e0fc12fd082f138cc2477bf0 (diff) | |
download | translated-content-aecf6d3acaa1fac94d24c53e1dda4cd136105df0.tar.gz translated-content-aecf6d3acaa1fac94d24c53e1dda4cd136105df0.tar.bz2 translated-content-aecf6d3acaa1fac94d24c53e1dda4cd136105df0.zip |
Add Error() constructor (#1154)
Diffstat (limited to 'files/ko')
-rw-r--r-- | files/ko/web/javascript/reference/global_objects/error/error/index.html | 81 | ||||
-rw-r--r-- | files/ko/web/javascript/reference/global_objects/error/index.html | 6 |
2 files changed, 82 insertions, 5 deletions
diff --git a/files/ko/web/javascript/reference/global_objects/error/error/index.html b/files/ko/web/javascript/reference/global_objects/error/error/index.html new file mode 100644 index 0000000000..11b495c777 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/error/error/index.html @@ -0,0 +1,81 @@ +--- +title: Error() 생성자 +slug: Web/JavaScript/Reference/Global_Objects/Error/Error +tags: + - Constructor + - JavaScript + - Reference +browser-compat: javascript.builtins.Error.Error +translation_of: Web/JavaScript/Reference/Global_Objects/Error/Error +--- + +<div>{{JSRef}}</div> + +<p> + <strong><code>Error</code></strong> 생성자는 오류 객체를 생성합니다. +</p> + +<h2 id="syntax">구문</h2> + +<pre class="brush: js"> +new Error() +new Error(message) +new Error(message, fileName) +new Error(message, fileName, lineNumber) +</pre> + +<h3 id="parameters">매개변수</h3> + +<dl> + <dt> + <code><var>message</var></code> {{Optional_Inline}} + </dt> + <dd>사람이 읽을 수 있는 오류 메시지입니다.</dd> + <dt> + <code><var>fileName</var></code> {{Optional_Inline}}{{Non-standard_inline}} + </dt> + <dd> + 생성할 <code>Error</code> 객체의 <code><var>fileName</var></code> 속성으로 설정할 값입니다. 기본 값은 + <code>Error()</code> 생성자를 호출한 파일의 이름입니다. + </dd> + <dt> + <code><var>lineNumber</var></code> {{Optional_Inline}}{{Non-standard_inline}} + </dt> + <dd> + 생성할 <code>Error</code> 객체의 <code><var>lineNumber</var></code> 속성으로 설정할 값입니다. 기본 값은 + <code>Error()</code> 생성자를 호출한 줄의 번호입니다. + </dd> +</dl> + +<h2 id="examples">예제</h2> + +<h3 id="function_call_or_new_construction">생성자 또는 함수 호출</h3> + +<p> + <code>Error</code>를 {{JSxRef("Operators/new", "new")}} 없이 함수로써 호출한 경우에도 <code>Error</code> 객체를 + 반환합니다. 따라서 단순히 <code>Error</code>를 호출하기만 해도 <code>new</code> 키워드를 사용한 것과 같은 결과를 + 낳습니다. +</p> + +<pre class="brush: js"> +// 함수로 호출해도... +const x = Error('함수 호출로 만들기!') + +// ...이렇게 생성자로 사용한 것과 같은 결과 +const y = new Error('"new" 키워드를 써서 만들기!') +</pre> + +<h2 id="specifications">명세</h2> + +{{Specifications}} + +<h2 id="browser_compatibility">브라우저 호환성</h2> + +<p>{{Compat}}</p> + +<h2 id="see_also">같이 보기</h2> + +<ul> + <li>{{JSxRef("Statements/throw", "throw")}}</li> + <li>{{JSxRef("Statements/try...catch", "try...catch")}}</li> +</ul> diff --git a/files/ko/web/javascript/reference/global_objects/error/index.html b/files/ko/web/javascript/reference/global_objects/error/index.html index 9eb672499f..b82f5dbbea 100644 --- a/files/ko/web/javascript/reference/global_objects/error/index.html +++ b/files/ko/web/javascript/reference/global_objects/error/index.html @@ -77,11 +77,7 @@ browser-compat: javascript.builtins.Error <h2 id="Constructor">생성자</h2> <dl> - <dt> - <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error" - ><code>Error()</code></a - > - </dt> + <dt>{{jsxref("Error/Error", "Error()")}}</dt> <dd>새로운 <code>Error</code> 객체를 만듭니다.</dd> </dl> |