请问怎么将这种代码 短路原理 改成if{}else{}语句

小飞飞丶F
  • 3
新手上路,请多包涵

opt[p] == iCur || (bComplete = false, this.css(p, iCur + iSpeed)) ;

bComplete && (clearInterval(this.timer), this.callback && this.callback.call(this))

回复
阅读 546
2 个回答
✓ 已被采纳

我是这么解读的

if(opt[p] !== iCur) {
   bComplete = false
   this.css(p, iCur + iSpeed)
}

if(bComplete) {
  clearInterval(this.timer)
  if(this.callback) {
    this.callback.call(this)
  }
} 
if(opt[p] != iCur) {
   bComplete = false
   this.css(p, iCur + iSpeed)
}

if(bComplete) {
  clearInterval(this.timer)
  if(this.callback) this.callback.call(this)
} 
你知道吗?

宣传栏