javascript/jquery:将运算符 !== 0 替换为 > 0 可能

发布于 2024-12-14 15:59:41 字数 145 浏览 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

携余温的黄昏 2024-12-21 15:59:46

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.

星星的軌跡 2024-12-21 15:59:45

是的,当且仅当该值不为负时。但 JavaScript 是一种很难做出这样断言的语言。

Yes, if and only if that value is not negative. But JavaScript is a language that is difficult to make such assertions.

月亮坠入山谷 2024-12-21 15:59:45

否。

"0" !== 0 为 true

"0" > 0 为假

No.

"0" !== 0 is true

"0" > 0 is false

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文