Tenali Raman
Tenali Raman

Reputation: 380

Why the check on e?

hey guys i am very new to Js and JQuery in general and basically i was just going through the code of carasoul.js and came across the below line of code ::

Carousel.prototype.pause = function (e) {

    e || (this.paused = true)

    if (this.$element.find('.next, .prev').length && $.support.transition) {
      this.$element.trigger($.support.transition.end)

    }

I have been debugging this plugin for a while to understand how the Jquery carousel works .

now if you have a closer look at the lines of code above , you'll see the below line of code ::

  e || (this.paused = true)

I understand that this line of code actually makes use of ternary operators and short circuiting , i managed to get my heaad around that , but what i don't understand is that why the check on e ?

i totally miss the point of the check on e , why that perticular check ? i console.logged and i see that it is false most of the time but , why the check ? can somebody explain explain please ?

Upvotes: 0

Views: 63

Answers (1)

feeela
feeela

Reputation: 29932

As noted above by @CBroe, this is a check for an event object inside an event handler. It looks like you can also call those methods directly and thus no event object is passed into the function and a default value to some object member is set.

It's hard to say where and why this is used without knowing the whole source code.

Upvotes: 1

Related Questions