javascript - problem with JS comparison logic if/and/or
问题描述
so here is the scenario
if ( ( a >= b) && ( (c < d) && (d != '') ) )
cannot get this logic on this to work correctly
so if d = '' it would cause that to be false. which would mean that the whole thing would equate to false. Problem is I need it to trigger when a >= b but also needs to include the and for c < d but only if d != '', in other words ignore the c < d part if d = '', otherwise used the c < d part to prevent a >= b from triggering.
hope this is making sense. I am trying to avoid doing and if/else or switch.
解决方案
感谢您的建议,虽然我只是提出了一个解决方法
if (d == '') { d = Infinity; }
然后
if ( (a >= b) && (c < d) )
这解决了它
感谢大家的帮助
推荐阅读
- firebase - 写入 Firebase Firestore 会导致数据与 UI 上查看的数据重复——Flutter?
- java - 我的数组只记住最后输入的最后一个元素,直方图打印不正确
- python - 如何使用变量来定义一个目录烧瓶python3
- ruby - 给定多个参数,在 ruby 中格式化整行
- stripe-payments - 我如何确保客户不会跳过带有条纹的付费专区?
- squarespace - 自定义 css 光标不适用于 vimeo 块
- azure - IIS 重写规则以排除虚拟目录
- r - 如何计算偏差标准信息到 mcmc 模型
- python - 是否可以获得(可能已装饰的)Python 函数体的源代码,包括内联注释?
- python - 我们如何在 Python 中删除 Google 电子表格中的行?