aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/javascript/reference/global_objects/math/min/index.html
blob: 6ab640e2cdb06aa304689fe0568a4c8b1d6f1322 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
title: Math.min()
slug: Web/JavaScript/Reference/Global_Objects/Math/min
translation_of: Web/JavaScript/Reference/Global_Objects/Math/min
---
<div>{{JSRef}}</div>

<p><strong><code>Math.min()</code></strong> 함수는 주어진 숫자들 중 가장 작은 값을 반환합니다.</p>

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

<pre class="syntaxbox"><code>Math.min([<var>value1</var>[, <var>value2</var>[, ...]]])</code></pre>

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

<dl>
 <dt><code>value1, value2, ...</code></dt>
 <dd>숫자형</dd>
</dl>

<h3 id="Return_value">Return value</h3>

<p>주어진 숫자들 중 가장 작은 값. 만약 적어도 1개 이상의 인자값이 숫자형으로 변환이 불가능 한 경우 이 함수는 {{jsxref("NaN")}} 를 반환 합니다.</p>

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

<p><code>min()</code> 함수는 <code>Math</code> 의 정적 메소드 이므로, 사용자가 생성한 <code>Math</code> 객체의 메소드로 호출하는 것이 아닌 항상 <code>Math.min()</code> 으로 호출되어야 합니다. (<code>Math</code> 는 생성자가 아닙니다).</p>

<p>만약 주어진 인자값이 없을 경우, {{jsxref("Infinity")}} 가 반환됩니다.</p>

<p>만약 적어도 1개 이상의 인자값이 숫자형으로 변환이 불가능 한 경우, {{jsxref("NaN")}} 가 반환됩니다.</p>

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

<h3 id="Using_Math.min()">Using <code>Math.min()</code></h3>

<p>아래 수식은 <code>x</code> 와<code>y</code> 중 작은 값을 찾아 <code>z</code> 에 할당 합니다.     </p>

<pre class="brush: js">var x = 10, y = -20;
var z = Math.min(x, y);
</pre>

<h3 id="Clipping_a_value_with_Math.min()">Clipping a value with <code>Math.min()</code></h3>

<p><code>Math.min()</code> 함수는 때때로 값 제한, 즉 항상 기준 보다 작거나 같은 값으로 제한하는 용도로 사용됩니다. 예를 들면,</p>

<pre class="brush: js">var x = f(foo);

if (x &gt; boundary) {
  x = boundary;
}
</pre>

<p> 위 코드는 다음과 같이 쓸 수 있습니다.</p>

<pre class="brush: js">var x = Math.min(f(foo), boundary);
</pre>

<p>{{jsxref("Math.max()")}} 함수 또한 같은 방식으로 기준보다 크거나 같은 값으로 제한하는 용도로 사용할 수 있습니다.</p>

<h2 id="Specifications">Specifications</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('ES1')}}</td>
   <td>{{Spec2('ES1')}}</td>
   <td>Initial definition. Implemented in JavaScript 1.0.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.8.2.12', 'Math.min')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-math.min', 'Math.min')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-math.min', 'Math.min')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

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

<p>{{Compat("javascript.builtins.Math.min")}}</p>

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

<ul>
 <li>{{jsxref("Math.max()")}}</li>
</ul>