aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/operators/expression_closures/index.html
blob: bf44be6cd7fab85651e1db43853f2ba2f539ead1 (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
---
title: 표현식 클로저
slug: Web/JavaScript/Reference/Operators/Expression_closures
tags:
  - Function
  - JavaScript
  - Non-standard
  - Obsolete
  - Operator
  - Reference
translation_of: Archive/Web/JavaScript/Expression_closures
---
<div>{{JSSidebar("Operators")}}{{Non-standard_Header}}{{Obsolete_Header("gecko60")}}
<div class="warning"><strong>Non-standard. Do not use!</strong><br>
The expression closure syntax is a deprecated Firefox-specific feature and has been removed starting with Firefox 60. For future-facing usages, consider using <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">arrow functions</a>.</div>
</div>

<p>클로져는 간단한 함수를 작성하기 위한 짧은 함수구문 입니다.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">function [<em>name</em>]([<em>param1</em>[, <em>param2[</em>, ..., <em>paramN</em>]]])
   <em>expression</em>
</pre>

<h3 id="Parameters">Parameters</h3>

<dl>
 <dt><code>name</code></dt>
 <dd>함수의 이름입니다. 익명함수의 경우에는 생략할 수 있습니다. 이름은 함수본문에만 국한됩니다.</dd>
 <dt><code>paramN</code></dt>
 <dd>함수에 전달할 인수의 이름입니다. 함수는 최대 255개의 인수를 가질 수 있습니다.</dd>
 <dt><code>expression</code></dt>
 <dd>함수의 본문을 구성하는 표현식입니다.</dd>
</dl>

<h2 id="Description">Description</h2>

<p>이 추가적인 기능은 <a class="external" href="http://en.wikipedia.org/wiki/Lambda_calculus#Lambda_calculus_and_programming_languages">람다 표기법</a>과 비슷한 언어를 제공하기위해 간단한 기능을 작성하는데 필요한 단축형일 뿐입니다.</p>

<p>JavaScript 1.7 and older:</p>

<pre class="brush: js">function(x) { return x * x; }</pre>

<p>JavaScript 1.8:</p>

<pre class="brush: js">function(x) x * x</pre>

<p>이 구문을 사용하면 중괄호나 'return'문을 생략하여 암시적으로 만들 수 있습니다. 코드를 더 짧게 만들 수 있는 것 이외의 이방법으로 얻을 수 있는 추가 이점은 없습니다.</p>

<h2 id="Examples">Examples</h2>

<p>바인딩 이벤트 리스너의 간단한 예제:</p>

<pre class="brush: js"> document.addEventListener('click', function() false, true);
</pre>

<p>JavaScript 1.6의 일부 배열 함수에 이 표기법을 사용합니다:</p>

<pre class="brush: js">elems.some(function(elem) elem.type == 'text');
</pre>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("javascript.operators.expression_closures")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{jsxref("Functions_and_function_scope", "Functions and function scope")}}</li>
 <li>{{jsxref("Function")}}</li>
 <li>{{jsxref("Statements/function", "function statement")}}</li>
 <li>{{jsxref("Operators/function", "function expression")}}</li>
 <li>{{jsxref("Statements/function*", "function* statement")}}</li>
 <li>{{jsxref("Operators/function*", "function* expression")}}</li>
 <li>{{jsxref("GeneratorFunction")}}</li>
</ul>