js callback && callback()

js 中有时会这么写:
callback
&& callback();

解释:

t's a shorthand conditional.

If the left of the && is truth-y, then whatever is on the right side of the && is executed.

This statement says that if callback is defined and truth-y (not null, false, or 0), execute it.

要是callback被定义了,那么执行callback()

 
http://stackoverflow.com/questions/19120317/what-does-callback-callback-mean-in-javascript

posted on 2014-04-27 17:59  Sure_Yi  阅读(1008)  评论(0编辑  收藏  举报

导航