aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/function/length/index.html
blob: f9e6b30adf0993c57cbc22d1a47866160f8a70b0 (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
---
title: Function.length
slug: Web/JavaScript/Reference/Global_Objects/Function/length
tags:
  - Function
  - JavaScript
  - Property
translation_of: Web/JavaScript/Reference/Global_Objects/Function/length
---
<div>{{JSRef}}</div>

<p><code><strong>length</strong></code> 속성은 함수가 기대하는 인수의 수를 나타냅니다.</p>

<p>{{EmbedInteractiveExample("pages/js/function-length.html")}}</p>

<div>{{js_property_attributes(0,0,1)}}</div>

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

<p><code>length</code>는 함수 객체의 속성으로, 함수가 얼마나 많은 인수를 기대하는지 나타냅니다, 즉 형식 매개변수의 수. 이 수는 {{jsxref("rest_parameters", "나머지 매개변수", "", 1)}}를 포함하지 않습니다. 그에 반해, {{jsxref("Functions/arguments/length", "arguments.length")}}는 함수에 지역(local)이고 실제로 함수에 전달된 인수의 수를 제공합니다.</p>

<h3 id="Function_생성자의_데이터_속성"><code>Function</code> 생성자의 데이터 속성</h3>

<p>{{jsxref("Function")}} 생성자는 그 자체로 {{jsxref("Function")}} 객체입니다. 그 <code>length</code> 데이터 속성은 값이 1입니다. 속성의 attribute: 쓰기가능(Writable): <code>false</code>, 열거가능(Enumerable): <code>false</code>, 설정가능(Configurable): <code>true</code>.</p>

<h3 id="Function_프로토타입_객체의_속성"><code>Function</code> 프로토타입 객체의 속성</h3>

<p>{{jsxref("Function")}} 프로토타입 객체의 length 속성은 값이 0입니다.</p>

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

<pre class="brush: js">console.log(Function.length); /* 1 */

console.log((function()        {}).length); /* 0 */
console.log((function(a)       {}).length); /* 1 */
console.log((function(a, b)    {}).length); /* 2 등. */
console.log((function(...args) {}).length); /* 0, 나머지 매개변수는 계산되지 않음 */
</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.3.5.1', 'Function.length')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-function-instances-length', 'Function.length')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>이 속성의 설정가능(<code>configurable</code>) attribute은 이제 <code>true</code>임.</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-function-instances-length', 'Function.length')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

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

<p>{{Compat("javascript.builtins.Function.length")}}</p>

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

<ul>
 <li>{{jsxref("Function")}}</li>
</ul>