I was looking into Raphael JS library but I see this:
Animation.prototype.delay = function (delay) {
var a = new Animation(this.anim, this.ms);
a.times = this.times;
a.del = +delay || 0;
return a;
};
What is the + operator before the delay variable?
Thanks.
It converts a String variable to a Number, if possible: +'21.2'
equals Number(21.2)
. If the conversion fails, it return NaN
(that's where || 0
kicks in in your example code)
It is a way to make a variable value to number, if the variable has a number. alternative you can use Number
function.
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