이 글은 기술 검토가 필요합니다. 도울을 줄 수 있는 방법을 살펴보세요.
이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 함께 해서 번역을 마치도록 도와 주세요!
In JavaScript, a truthy value is a value that translates to true
when evaluated in a Boolean context. All values are truthy unless they are defined as falsy (i.e., except for false
, 0
, ""
, null
, undefined
, and NaN
).
JavaScript uses type coercion in Boolean contexts.
Examples of truthy values in JavaScript (which will translate to true and thus execute the if
block):
if (true) if ({}) if ([]) if (42) if ("foo") if (new Date()) if (-42) if (3.14) if (-3.14) if (Infinity) if (-Infinity)