【发布时间】:2015-06-21 23:06:05
【问题描述】:
parent && (this.parent.next = this); 这一行是什么意思?
它看起来就像它坐在那里,什么都不做,而不是 if 语句或承诺或任何东西。这种编码风格有名字吗?
var Particle = function(i, parent)
{
this.next = null;
this.parent = parent;
parent && (this.parent.next = this);
this.img = new Image();
this.img.src = "http://www.dhteumeuleu.com/images/cloud_01.gif";
this.speed = speed / this.radius;
}
它在我正在查看的这个动画文件中的多个位置。这是另一个例子..(!touch && document.setCapture) && document.setCapture();
this.down = function(e, touch)
{
e.preventDefault();
var pointer = touch ? e.touches[0] : e;
(!touch && document.setCapture) && document.setCapture();
this.pointer.x = pointer.clientX;
this.pointer.y = pointer.clientY;
this.pointer.isDown = true;
【问题讨论】:
标签: javascript short-circuiting