aboutsummaryrefslogtreecommitdiff
path: root/files/ko/glossary/truthy/index.html
blob: ae92e41292c314f77fc95597040b28ed890f3059 (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
---
title: 참 같은 값
slug: Glossary/Truthy
tags:
  - CodingScripting
  - Glossary
  - JavaScript
translation_of: Glossary/Truthy
---
<p>{{Glossary("JavaScript")}}에서, <strong>참 같은 값</strong>(Truthy)인 값이란 {{Glossary("Boolean", "불리언")}}을 기대하는 문맥에서 <code>true</code>로 평가되는 값입니다. 따로 {{Glossary("Falsy", "거짓 같은 값")}}으로 정의된 값이 아니면 모두 참 같은 값으로 평가됩니다. (예: <code>false</code><code>0</code><code>-0</code><code>0n</code><code>""</code><code>null</code><code>undefined</code>와 <code>NaN</code> 등)</p>

<p>JavaScript는 불리언 문맥에서 {{Glossary("Type_Conversion", "형 변환")}}을 사용합니다.</p>

<p>다음은 참 같은 값에 대한 예시입니다. JavaScript는 불리언 문맥에서 참 같은 값을 <code>true</code>로 변환하기 때문에 아래의 모든 <code>if</code> 블록을 실행합니다.</p>

<pre class="notranslate">if (true)
if ({})
if ([])
if (42)
if ("0")
if ("false")
if (new Date())
if (-42)
if (12n)
if (3.14)
if (-3.14)
if (Infinity)
if (-Infinity)</pre>

<h2 id="Specifications">Specifications</h2>

<table>
 <thead>
  <tr>
   <th scope="col">Specification</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("ESDraft", "#sec-toboolean", "<code>ToBoolean</code> abstract operation")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="같이_보기">같이 보기</h2>

<ul>
 <li>{{Glossary("Falsy", "거짓 같은 값")}}</li>
 <li>{{Glossary("Type_Conversion", "형변환")}}</li>
 <li>{{Glossary("Boolean", "불리언")}}</li>
</ul>

<div>{{QuickLinksWithSubpages("/ko/docs/Glossary")}}</div>