- JavaScript 基础教程
- JavaScript - 主页
- JavaScript - 概述
- JavaScript - 语法
- JavaScript - 启用
- JavaScript - 放置
- JavaScript - 变量
- JavaScript - 运算符
- JavaScript - 如果...否则
- Javascript - 切换大小写
- JavaScript - While 循环
- JavaScript - For 循环
- Javascript - 对于...in
- Javascript - 循环控制
- JavaScript - 函数
- Javascript - 事件
- JavaScript - Cookie
- JavaScript - 页面重定向
- JavaScript - 对话框
- Javascript - 无效关键字
- Javascript - 页面打印
- JavaScript 对象
- JavaScript - 对象
- JavaScript - 数字
- JavaScript - 布尔值
- JavaScript - 字符串
- JavaScript - 数组
- JavaScript - 日期
- JavaScript - 数学
- JavaScript - 正则表达式
- JavaScript - HTML DOM
- JavaScript 高级
- JavaScript - 错误处理
- Javascript - 验证
- JavaScript - 动画
- JavaScript - 多媒体
- JavaScript - 调试
- Javascript - 图像映射
- JavaScript - 浏览器
- JavaScript 有用资源
- JavaScript - 问题与解答
- JavaScript - 快速指南
- JavaScript - 函数
- JavaScript - 资源
JavaScript - The Boolean Object
The Boolean object represents two values, either "true" or "false". If value parameter is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (""), the object has an initial value of false.
Syntax
Use the following syntax to create a boolean object.
var val = new Boolean(value);
Boolean Properties
Here is a list of the properties of Boolean object −
Sr.No. | Property & Description |
---|---|
1 | constructor
Returns a reference to the Boolean function that created the object. |
2 | prototype
The prototype property allows you to add properties and methods to an object. |
In the following sections, we will have a few examples to illustrate the properties of Boolean object.
Boolean Methods
Here is a list of the methods of Boolean object and their description.
Sr.No. | Method & Description |
---|---|
1 | toSource()
Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object. |
2 | toString()
Returns a string of either "true" or "false" depending upon the value of the object. |
3 | valueOf()
Returns the primitive value of the Boolean object. |
In the following sections, we will have a few examples to demonstrate the usage of the Boolean methods.