javascript/jquery:将运算符 !== 0 替换为 > 0 可能
我想知道:
我有一个公式可以检查 if some !== 0
如果我确定某些东西不能为负,我可以将 !== 0 替换为 <强>> 0 并且总是得到相同的结果?
I'm wondering:
I have a formula that checks if something !== 0
If I'm sure something cannot be negativ, can I replace !== 0 with > 0 and always get the same result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
javascript 中有 ===
所以如果 x = 5
那么 x === 5 为 true
但 x === '5' 为 false
,但对于 == 两者都会返回 true。
There is a === in javascript
so if x = 5
then x === 5 is true
but x === '5' is false
but for == both will return true.
是的,当且仅当该值不为负时。但 JavaScript 是一种很难做出这样断言的语言。
Yes, if and only if that value is not negative. But JavaScript is a language that is difficult to make such assertions.
否。
"0" !== 0
为 true"0" > 0
为假No.
"0" !== 0
is true"0" > 0
is false