aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/statements/class
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:17 -0500
commitda78a9e329e272dedb2400b79a3bdeebff387d47 (patch)
treee6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ko/web/javascript/reference/statements/class
parent1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff)
downloadtranslated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz
translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2
translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip
initial commit
Diffstat (limited to 'files/ko/web/javascript/reference/statements/class')
-rw-r--r--files/ko/web/javascript/reference/statements/class/index.html119
1 files changed, 119 insertions, 0 deletions
diff --git a/files/ko/web/javascript/reference/statements/class/index.html b/files/ko/web/javascript/reference/statements/class/index.html
new file mode 100644
index 0000000000..bfb1c95027
--- /dev/null
+++ b/files/ko/web/javascript/reference/statements/class/index.html
@@ -0,0 +1,119 @@
+---
+title: class
+slug: Web/JavaScript/Reference/Statements/class
+tags:
+ - Classes
+ - Declaration
+ - ECMAScript 2015
+ - JavaScript
+ - Reference
+ - Statement
+translation_of: Web/JavaScript/Reference/Statements/class
+---
+<div>{{jsSidebar("Statements")}}</div>
+
+<p><strong><code>class</code> 선언</strong>은 프로토타입 기반 상속을 사용하여, 주어진 이름의 새로운 클래스를 만듭니다.</p>
+
+<div>{{EmbedInteractiveExample("pages/js/statement-class.html")}}</div>
+
+
+
+<div class="noinclude">
+<p>{{jsxref("Operators/class", "클래스 표현", "", 1)}}을 사용하여 클래스를 정의할 수도 있습니다. 표현식과 달리 선언문으로는 같은 클래스를 다시 선언하면 오류가 발생합니다.</p>
+</div>
+
+<h2 id="구문">구문</h2>
+
+<pre class="syntaxbox">class <em>name</em> [extends] {
+ // class body
+}
+</pre>
+
+<h2 id="설명">설명</h2>
+
+<p>클래스 본문은 <a href="/ko/docs/Web/JavaScript/Reference/Strict_mode">엄격 모드</a>에서 실행됩니다. 생성자 속성은 선택 사항입니다..</p>
+
+<p>클래스 선언은 {{jsxref("Statements/function", "함수 선언", "", 0)}}과 달리 {{Glossary("Hoisting", "호이스팅")}}의 대상이 아닙니다.</p>
+
+<h2 id="예제">예제</h2>
+
+<h3 id="간단한_클래스_선언">간단한 클래스 선언</h3>
+
+<p>다음 예제는 우선 <code>Polygon</code> 클래스를 정의하고, <code>Square</code>라는 이름의 새로운 클래스가 <code>Polygon</code>을 상속합니다. 생성자 내부의 <code>super()</code>는 생성자 내에서만, 그리고 {{jsxref("Operators/this", "this")}} 키워드를 사용하기 전에만 쓸 수 있다는 점을 주의하세요.</p>
+
+<pre class="brush: js">class Polygon {
+ constructor(height, width) {
+ this.name = 'Polygon';
+ this.height = height;
+ this.width = width;
+ }
+}
+
+class Square extends Polygon {
+ constructor(length) {
+ super(length, length);
+  this.name = 'Square';
+ }
+}</pre>
+
+<div class="warning">
+<h3 id="같은_클래스를_두_번_선언하려고_시도할_때">같은 클래스를 두 번 선언하려고 시도할 때</h3>
+
+<p>클래스 선언문으로 같은 클래스를 두 번 선언하면 오류가 발생합니다.</p>
+
+<pre class="brush: js">class Foo {};
+class Foo {}; // Uncaught SyntaxError: Identifier 'Foo' has already been declared
+</pre>
+
+<p>이전에 표현식으로 정의한 경우에도 오류가 발생합니다.</p>
+
+<pre class="brush: js">var Foo = class {};
+class Foo {}; // Uncaught TypeError: Identifier 'Foo' has already been declared
+</pre>
+</div>
+
+<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('ES2015', '#sec-class-definitions', 'Class definitions')}}</td>
+ <td>{{Spec2('ES2015')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES2016', '#sec-class-definitions', 'Class definitions')}}</td>
+ <td>{{Spec2('ES2016')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES2017', '#sec-class-definitions', 'Class definitions')}}</td>
+ <td>{{Spec2('ES2017')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-class-definitions', 'Class definitions')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="브라우저_호환성">브라우저 호환성</h2>
+
+
+
+<p>{{Compat("javascript.statements.class")}}</p>
+
+<h2 id="참조">참조</h2>
+
+<ul>
+ <li>{{jsxref("Statements/function", "function")}} 선언문</li>
+ <li>{{jsxref("Operators/class", "class")}} 표현식</li>
+ <li><a href="/ko/docs/Web/JavaScript/Reference/Classes">클래스</a></li>
+</ul>