aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/function/name/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ko/web/javascript/reference/global_objects/function/name/index.html')
-rw-r--r--files/ko/web/javascript/reference/global_objects/function/name/index.html191
1 files changed, 191 insertions, 0 deletions
diff --git a/files/ko/web/javascript/reference/global_objects/function/name/index.html b/files/ko/web/javascript/reference/global_objects/function/name/index.html
new file mode 100644
index 0000000000..ce2d665b73
--- /dev/null
+++ b/files/ko/web/javascript/reference/global_objects/function/name/index.html
@@ -0,0 +1,191 @@
+---
+title: Function.name
+slug: Web/JavaScript/Reference/Global_Objects/Function/name
+tags:
+ - ECMAScript6
+ - Function
+ - JavaScript
+ - Property
+translation_of: Web/JavaScript/Reference/Global_Objects/Function/name
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong><em>function</em>.name</strong></code> 속성(property)은 함수 이름을 반환합니다.</p>
+
+<div>{{js_property_attributes(0,0,1)}}</div>
+
+<p>비표준, ES6 이전 구현에서는 설정가능(<code>configurable</code>) attribute도 <code>false</code>였음을 주의하세요.</p>
+
+<h2 id="설명">설명</h2>
+
+<p><code>name</code> 속성은 함수 이름 또는 (ES6 구현 이전) 익명(anonymous) 함수에 대해서는 빈 문자열을 반환합니다:</p>
+
+<pre class="brush: js">function doSomething() {}
+
+console.log(doSomething.name); // logs "doSomething"
+</pre>
+
+<p><code>new Function(...)</code> 또는 그냥 <code>Function(...)</code> 구문으로 생성된 함수는 <code>name</code> 속성을 빈 문자열로 설정합니다. 다음 예에서는 익명 함수가 생성되므로 <code>name</code>은 빈 문자열을 반환합니다:</p>
+
+<pre class="brush: js">var f = function() {};
+var object = {
+ someMethod: function() {}
+};
+
+console.log(f.name == ''); // true
+console.log(object.someMethod.name == ''); // 역시 true
+</pre>
+
+<p>ES6 함수를 구현한 브라우저는 익명 함수 이름을 그 구문상 위치로부터 추측할 수 있습니다. 예를 들어:</p>
+
+<pre class="brush: js">var f = function() {};
+console.log(f.name); // "f"</pre>
+
+<p>{{jsxref("Operators/Function", "function 식", "", 1)}}에서 이름으로 함수를 정의할 수 있습니다:</p>
+
+<pre class="brush: js">var object = {
+ someMethod: function object_someMethod() {}
+};
+console.log(object.someMethod.name); // logs "object_someMethod"
+
+try { object_someMethod } catch(e) { console.log(e); }
+// ReferenceError: object_someMethod가 정의되지 않음
+</pre>
+
+<p>함수 이름은 바꿀 수 없습니다, 이 속성은 읽기 전용입니다:</p>
+
+<pre class="brush: js">var object = {
+ // 익명
+ someMethod: function() {}
+};
+
+object.someMethod.name = 'someMethod';
+console.log(object.someMethod.name); // 빈 문자열, someMethod는 익명
+</pre>
+
+<p>그러나 바꾸려면, {{jsxref("Object.defineProperty()")}}를 사용할 수 있습니다.</p>
+
+<h2 id="예">예</h2>
+
+<p>객체의 'class'를 확인하기 위해 <code>obj.constructor.name</code>을 사용할 수 있습니다:</p>
+
+<pre class="brush: js">function a() {}
+
+var b = new a();
+
+console.log(b.constructor.name); // logs "a"
+</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('ES6', '#sec-name', 'name')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td>초기 정의.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-name', 'name')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="브라우저_호환성">브라우저 호환성</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome(33.0)}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td>Configurable: true</td>
+ <td>{{CompatChrome(43.0)}}</td>
+ <td>{{CompatGeckoDesktop(38)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td>Inferred names on anonymous functions</td>
+ <td>{{CompatChrome(51.0)}}</td>
+ <td>{{CompatNo}} [1]</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Android Webview</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ <tr>
+ <td>Configurable: true</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile(38)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td>Inferred names on anonymous functions</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome(51.0)}}</td>
+ <td>{{CompatNo}} [1]</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatChrome(51.0)}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] {{bug(883377)}} 참조.</p>