它是常见的一种语言evalute未定义为等于假的?如果是这样,这是为什么呢? [英] Is it common for a language to evalute undefined as equal to false? If so, why is this done?

查看:250
本文介绍了它是常见的一种语言evalute未定义为等于假的?如果是这样,这是为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:问题仍未得到解决。 @Alastair_Pitts:除非我失去了一些东西,这是一个问题的两个部分。第二部分,如果是这样,这是为什么呢?并没有得到回答。

UPDATE: Question still unanswered. @Alastair_Pitts: Unless I'm missing something, it's a two part question. The second part, "If so, why is this done?" and not been answered.

相信这个问题是清楚的,但如果你有任何问题 - 只要让我知道。谢谢!

Believe the question is clear, but if you have any questions -- just let me know. Thanks!

未定义=未知并是系统的引用基于三元逻辑。

undefined = unknown and is a reference to system based on ternary logic.

参考:
http://en.wikipedia.org/wiki/Ternary_logic

推荐答案

在许多,如果不是大多数,语言值要么falsy,这意味着一些不存在或缺乏的值,或truthy,这意味着某物存在,或具有值。 falsy值的列表通常是:(这些评估为false)

In many, if not most, languages values are either falsy, meaning that something doesn't exist or lacks value, or truthy, meaning that something exists or has value. The list of falsy values is usually: (these evaluate to false)


  1. 0(零,数)

  2. ''(空字符串)

  3. 空(如果该值存在)

  4. 不确定(如果此值存在​​)

  5. 假/伪(如果它有一个布尔类型)

还有什么是truthy并评估为true。

Anything else is truthy and evaluates to true.

编辑:作出的回答有点不太偏向的JavaScript

Made the answer a bit less biased towards JavaScript

这篇关于它是常见的一种语言evalute未定义为等于假的?如果是这样,这是为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆