[英]Are these comparisons equivalent in Javascript?
In Javascript, is 在Javascript中,是
return (someBooleanValue == true)
necessarily always the same as 一定总是和
return someBooleanValue
? ?
Iff someBooleanValue
is a boolean value, then yes. 如果f
someBooleanValue
是布尔值,则为是。 For any other object/value, then no. 对于其他任何对象/值,则否。
If you assume that typeof someBooleanValue
is 'boolean'
, then Yes these are equivalent (by pure boolean logic). 如果您假设
typeof someBooleanValue
为'boolean'
,则是的,它们是等效的(通过纯布尔逻辑)。
For everything else, they are not. 对于其他一切,它们不是。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.