aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/object/constructor
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/global_objects/object/constructor
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/global_objects/object/constructor')
-rw-r--r--files/ko/web/javascript/reference/global_objects/object/constructor/index.html155
1 files changed, 155 insertions, 0 deletions
diff --git a/files/ko/web/javascript/reference/global_objects/object/constructor/index.html b/files/ko/web/javascript/reference/global_objects/object/constructor/index.html
new file mode 100644
index 0000000000..0162140d9c
--- /dev/null
+++ b/files/ko/web/javascript/reference/global_objects/object/constructor/index.html
@@ -0,0 +1,155 @@
+---
+title: Object.prototype.constructor
+slug: Web/JavaScript/Reference/Global_Objects/Object/constructor
+tags:
+ - JavaScript
+ - Object
+ - Property
+ - Prototype
+ - Reference
+translation_of: Web/JavaScript/Reference/Global_Objects/Object/constructor
+---
+<div>{{JSRef}}</div>
+
+<p>인스턴스의 프로토타입을 만든 {{jsxref("Object")}} 함수의 참조를 반환합니다. 이 속성값은 함수 자체의 참조임을 주의하세요, 함수 이름을 포함하는 문자열이 아니라. 그 값은 <code>1</code>, <code>true</code> 및 <code>"test"</code>와 같은 원시(primitive) 값에 대해서만 읽기 전용입니다.</p>
+
+<h2 id="설명">설명</h2>
+
+<p>모든 객체는 자신의 <code>prototype</code>으로부터 <code>constructor</code> 속성을 상속합니다:</p>
+
+<pre>var o = {};
+o.constructor === Object; // true
+
+var o = new Object;
+o.constructor === Object; // true
+
+var a = [];
+a.constructor === Array; // true
+
+var a = new Array;
+a.constructor === Array; // true
+
+var n = new Number(3);
+n.constructor === Number; // true</pre>
+
+<h2 id="예제">예제</h2>
+
+<h3 id="객체의_생성자_표시하기">객체의 생성자 표시하기</h3>
+
+<p>다음 예는 프로토타입이 <code>Tree</code>인 그 형의 객체 <code>theTree</code>를 만듭니다. 그 다음 객체 <code>theTree</code>의 <code>constructor</code>를 표시합니다.</p>
+
+<pre class="brush: js">function Tree(name) {
+ this.name = name;
+}
+
+var theTree = new Tree('Redwood');
+console.log('theTree.constructor is ' + theTree.constructor);
+</pre>
+
+<p>이 예는 다음 출력을 표시합니다:</p>
+
+<pre class="brush: js">theTree.constructor is function Tree(name) {
+ this.name = name;
+}
+</pre>
+
+<h3 id="객체의_생성자_바꾸기">객체의 생성자 바꾸기</h3>
+
+<p>다음 예는 일반 객체의 constructor 값을 수정하는 법을 보입니다. <code>true</code>, <code>1</code> 및 <code>"test"</code>만이 원래 읽기 전용 생성자를 갖기에 영향을 받지 않습니다. 이 예는 객체의 <code>constructor</code> 속성에 의존하는 게 항상 안전하지는 않음을 보입니다.</p>
+
+<pre class="brush:js">function Type () {}
+
+var types = [
+ new Array(),
+ [],
+ new Boolean(),
+ true, // 바뀌지 않음
+ new Date(),
+ new Error(),
+ new Function(),
+ function () {},
+ Math,
+ new Number(),
+ 1, // 바뀌지 않음
+ new Object(),
+ {},
+ new RegExp(),
+ /(?:)/,
+ new String(),
+ 'test' // 바뀌지 않음
+];
+
+for (var i = 0; i &lt; types.length; i++) {
+ types[i].constructor = Type;
+ types[i] = [types[i].constructor, types[i] instanceof Type, types[i].toString()];
+}
+
+console.log(types.join('\n'));
+</pre>
+
+<p>이 예는 다음 출력을 표시합니다:</p>
+
+<pre class="brush: js">function Type() {},false,
+function Type() {},false,
+function Type() {},false,false
+function Boolean() {
+ [native code]
+},false,true
+function Type() {},false,Mon Sep 01 2014 16:03:49 GMT+0600
+function Type() {},false,Error
+function Type() {},false,function anonymous() {
+
+}
+function Type() {},false,function () {}
+function Type() {},false,[object Math]
+function Type() {},false,0
+function Number() {
+ [native code]
+},false,1
+function Type() {},false,[object Object]
+function Type() {},false,[object Object]
+function Type() {},false,/(?:)/
+function Type() {},false,/(?:)/
+function Type() {},false,
+function String() {
+ [native code]
+},false,test
+</pre>
+
+<h2 id="명세">명세</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">명세</th>
+ <th scope="col">상태</th>
+ <th scope="col">설명</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES1')}}</td>
+ <td>{{Spec2('ES1')}}</td>
+ <td>초기 정의. JavaScript 1.1에서 구현됨.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.2.4.1', 'Object.prototype.constructor')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-object.prototype.constructor', 'Object.prototype.constructor')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-object.prototype.constructor', 'Object.prototype.constructor')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="브라우저_호환성">브라우저 호환성</h2>
+
+<div>{{Compat("javascript.builtins.Object.constructor")}}</div>
+
+<div id="compat-mobile"> </div>