Reputation: 122052
Browsing the d3 source code today I saw the following line:
return delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time), 1;
I've been doing daily javascript for years and have never seen that before. What the hey?
Upvotes: 2
Views: 181
Reputation: 2672
it means if the left hand operand is less than or equal to the right hand operand in nearly(if not all) languages
Upvotes: 1
Reputation: 161457
It is just less-than or equal. Maybe the Ternary operator combined with the comma operator is what is throwing you off?
This is equivalent to this:
if (delay < elapsed) start(elapsed);
else if (delay === elapsed) start(elapsed);
else {
d3.timer(start, delay, time);
}
return 1;
Upvotes: 14
Reputation: 69663
<= means less-or-equal.
The complete line you posted means in plain english "if delay is less than elapsed, return start(elapsed), otherwise return the value of d3.timer.
Upvotes: 0