i was just going through the unslider plugin code and i needed to customize this plugin as i want to make my webside carouself responsive .
now when i was going through the code , i came across the following:
o.autoplay && setTimeout(function() {
if (o.delay | 0) {
_this.play();
if (o.pause) {
el.on('mouseover mouseout', function(e) {
_this.stop();
e.type == 'mouseout' && _this.play();
});
};
};
}, o.init | 0);
I Have't honestly seen anything like this in javascript , is the above an if statement ?
my interpretation of the above is something like :
if(o.autoplay){
setTimeout(function() {
if (o.delay | 0) {
_this.play();
if (o.pause) {
el.on('mouseover mouseout', function(e) {
_this.stop();
e.type == 'mouseout' && _this.play();
});
};
};
}, o.init | 0);
} // end if
that's the best i could do by myself , now i also tried understanding each component of the code individually , i went through the doc's for the && operator , and i understand the how the setInterval function works .
but no where online , i have seen the the && operator being used the way it is used here .
so to sum up my question , What is this o.autoplay &&
doing before the setTimeOut function ?? is this some kind of a design pattern ??
EDIT ::
Also why the o.init | 0
parameter to the setTimeout function ?? i understand o.init being passed , as it a user defined value being sent to the plugin , but why the | 0
? Please explain .
Thank you .
Alexander.