【发布时间】:2015-04-25 00:42:35
【问题描述】:
大家好,我是 JS 和 jQuery 的新手,我刚刚浏览了 carousel.js 的源代码,发现了以下代码行:
this.cycle(true)
现在循环函数看起来像这样:
Carousel.prototype.cycle = function (e) {
// console.log('inside cycle');
e || (this.paused = false)
this.interval && clearInterval(this.interval)
this.options.interval
&& !this.paused
&& (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
return this
}
如果我console.log(e),我永远不会得到“真实”为什么?
我所指的行可以找到here。
有人可以向我解释为什么 this.cycle() 在该行被传递值 true 吗?
谢谢。
【问题讨论】:
-
这是另一个不以像
e || (this.paused = false)这样糟糕的方式编写代码的原因
标签: javascript jquery twitter-bootstrap carousel