js boolean

The Boolean object is used to convert a non-Boolean value to a Boolean value (true or false).
布尔对象用来把一个非布尔型的值转换为布尔值(真或假)


--------------------------------------------------------------------------------

Examples
举例
Check Boolean value [检查布尔对象]
Check if a Boolean object is true or false.
检查布尔对象(返回的值)是真还是假

Tip: You will find more examples in the Boolean object reference - look at the bottom of this page!
提示:你将在页底的Boolean object reference找到更多的例子!


--------------------------------------------------------------------------------

Boolean Object
布尔对象
The Boolean object is an object wrapper for a Boolean value.
布尔对象是布尔值的包装对象。

The Boolean object is used to convert a non-Boolean value to a Boolean value (true or false).
布尔对象是用来将非布尔型的值转换成一个布尔值(真或假)

We define a Boolean object with the new keyword. The following code line defines a Boolean object called myBoolean:
我们用一新关键字定义一个布尔对象。下面的代码定义了一个名为myBoolean的布尔对象:

var myBoolean=new Boolean()

Note: If the Boolean object has no initial value or if it is 0, -0, null, "", false, undefined, or NaN, the object is set to false. Otherwise it is true (even with the string "false")!
注意:如果布尔对象没有初始值或是0,-0,null,"",false,无定义的,或NaN,对象就设置为假.不然它就是真(哪怕是字符串值为"false")

All the following lines of code create Boolean objects with an initial value of false:
下面所有的代码建立的布尔对象的值都为false(假):

var myBoolean=new Boolean()var myBoolean=new Boolean(0)var myBoolean=new Boolean(null)var myBoolean=new Boolean("")var myBoolean=new Boolean(false)var myBoolean=new Boolean(NaN)

And all the following lines of code create Boolean objects with an initial value of true:
下面的就全为true(真):

var myBoolean=new Boolean(true)var myBoolean=new Boolean("true")var myBoolean=new Boolean("false")var myBoolean=new Boolean("Richard")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值