What does this line parent && (this.parent.next = this);
mean?
It just looks like its sitting there, doing nothing, not an if statement or a promise or anything. Is there a name for this style of coding?
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;
}
Its in multiple places in this animation file I'm looking at. Here's another example.. (!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;
Word forms: plural expressions. 1. variable noun. The expression of ideas or feelings is the showing of them through words, actions, or artistic activities. Laughter is one of the most infectious expressions of emotion. [
expression noun (SHOWING) the act of saying what you think or showing how you feel using words or actions: He wrote her a poem as an expression of his love. We've received a lot of expressions of support for our campaign.
The definition of an example of expression is a frequently used word or phrase or it is a way to convey your thoughts, feelings or emotions. An example of an expression is the phrase "a penny saved is a penny earned." An example of an expression is a smile.
It's shorthand for
if (parent) {
this.parent.next = this
}
if parent is false then not eject (this.parent.next = this), example:
parent = false;
parent && alert("not run");
Short-Circuit Evaluation:
As logical expressions are evaluated left to right, is named "short-circuit" evaluation,
variable && (anything); // anything is evaluated if variable = true.
variable || (anything); // anything is evaluated if variable = false
it's possible to use for assignment of variables:
var name = nametemp || "John Doe"; // assignment defaults if nametemp is false
var name = isValid(person) && person.getName(); //assignement if person is valid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With