这是相同的:
Boolean(MyObject.SomeText.length)
- 回报
true
如果MyObject.SomeText.length
= 0
- 回报
false
如果MyObject.SomeText.length
== 0
和
Boolean(MyObject.SomeText.length>0)
!
- 返回
true
如果MyObject.SomeText.length
> 0
- 返回
false
如果MyObject.SomeText.length
< = 0
但是MyObject.SomeText.length
只能是0
或正integrer。所以
- 如果
MyObject.SomeText.length
== 0,
Boolean(MyObject.SomeText.length)
回报false
因为MyObject.SomeText.length
== 0
Boolean(MyObject.SomeText.length>0)
回报false
因为MyObject.SomeText.length
< = 0
- 如果
MyObject.SomeText.length
> 0,
Boolean(MyObject.SomeText.length)
返回true
因为MyObject.SomeText.length
!= 0
Boolean(MyObject.SomeText.length>0)
返回true
因为MyObject.SomeText.length
> 0
只要.length'是在'值范围'[0,∞]',应该没问题。 – 2012-08-16 17:05:49
为什么你又问一个非常类似的问题? http://stackoverflow.com/questions/8423754/javascript-testing-object-property-length – micnic 2012-08-16 17:08:50
他的另一个问题:http://stackoverflow.com/questions/8424275/javascript-testing-length再次长度为 你是痴迷于长度? – micnic 2012-08-16 17:19:13