Files
freeCodeCamp/guide/chinese/javascript/standard-objects/boolean/index.md
2018-10-16 21:32:40 +05:30

17 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Boolean
localeTitle: 布尔
---
## 布尔
Boolean对象是布尔值true或false的对象包装器。您可以将布尔值显式定义为`new Boolean([value])` 。可选的`value`参数将转换为布尔值。如果未指定value `0` `-0` `null` `false` `NaN` `undefined`或空字符串( `""` 则将对象设置为false。所有其他值包括任何对象或字符串“false”都会创建值为true的对象。一个有趣的例外是当DOM的`document.all`作为参数传递给`Boolean`构造函数时,它被评估为`false` 1 。
布尔基元值( `true``false` )与`Boolean`对象值( `true``false` )不同。
#### 更多信息:
[JavaScript中布尔对象与布尔基元的区别 - 一滴JavaScript](http://adripofjavascript.com/blog/drips/the-difference-between-boolean-objects-and-boolean-primitives-in-javascript.html)
### 来源
1. [你不知道JavaScript第4章](https://github.com/getify/You-Dont-Know-JS/blob/master/types%20&%20grammar/ch4.md) 364行。 2017年10月31日访问。