MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

这篇翻译不完整。请帮忙从英语翻译这篇文章

A falsy value is a value that translates to false when evaluated in a Boolean context.

JavaScript uses type Type Conversion to coerce any value to a Boolean in contexts that require it, such as conditionals and loops.

Examples

Examples of falsy values in JavaScript (which translate to false and thus bypass the if block):

if (false)
if (null)
if (undefined)
if (0)
if (NaN)
if ('')
if ("")
if (document.all) [1]

[1] document.all has been used for browser detection in the past and the HTML specification defines a willful violation of the ECMAScript standard here to keep compatibility with legacy code (if (document.all) { // Internet Explorer code here } or using document.all without checking its presence first: document.all.foo).

Sometimes written falsey, although in English usually turning a word into an adjective with a -y, any final e is dropped (noise => noisy, ice => icy, shine => shiny)

Learn more

文档标签和贡献者

 此页面的贡献者: LiuL0703
 最后编辑者: LiuL0703,