From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/glossary/boolean/index.html | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 files/zh-cn/glossary/boolean/index.html (limited to 'files/zh-cn/glossary/boolean/index.html') diff --git a/files/zh-cn/glossary/boolean/index.html b/files/zh-cn/glossary/boolean/index.html new file mode 100644 index 0000000000..7ca234b21f --- /dev/null +++ b/files/zh-cn/glossary/boolean/index.html @@ -0,0 +1,48 @@ +--- +title: Boolean +slug: Glossary/Boolean +translation_of: Glossary/Boolean +--- +

在计算机科学中,布尔值是一种取值仅能为 真 或 假 的数据类型,它赋予了编程语言在逻辑上表达真 或 假 的能力。如果没有这种能力,很多功能将无法被实现。举个例子,JavaScript中的 if 语句 需要一些判断条件来决定接下来的代码会否被执行,而这些条件,本质上会被解释成一个布尔值。又如JavaScript中的 for 循环,如果没有一个能够解释成布尔值的判断条件,循环将无法知道自己什么时候该结束。

+ +
***JavaScript if 语句***
+if(boolean conditional) {
+   //代码
+}
+
+if(true) {
+  console.log("布尔值判断条件被解释为 真");
+} else {
+    console.log("布尔值判断条件被解释为 假");
+}
+
+
+
+***JavaScript for 循环***
+for(control variable; boolean conditional; counter) {
+  //代码
+}
+
+for(var i=0; i<4; i++) {
+  console.log("只有当布尔值判断条件为 真 的时候才,这段文字才会被打印");
+}
+
+ +

 

+ +

 

+ +

了解更多

+ +

通用知识

+ + + +

技术参考文档

+ + -- cgit v1.2.3-54-g00ecf