0

In the following code, there are two 'e's, are they about the same object/type or actually about different things?

(function(e) {
  var t = {
    init: function() {
      e(".pic").length && this.show()
    }
  };
  window.Booth = t;
})(jQuery);

Also, I am a little confused with the overall semantics of the code snippet above, any documentation out there can explain it?

3
  • 1
    There is no purpose, really. It's an abbreviation of 'event', and is used to refer to the local function.
    – Jack
    Apr 3, 2014 at 0:32
  • 1
    @JackWilliams Pay a-bloody-ttention, all right? Apr 3, 2014 at 0:33
  • Can anyone please remove the duplicate link? This is really not a duplicate. My rating got moved down 2 points because of the wrong judgement. I did see the Q earlier and realized that it doesn't answer my question.
    – bcbishop
    Apr 3, 2014 at 0:54

2 Answers 2

5

In this case, it's an alias for jQuery. Usually people use $, but in this case they didn't.

2

what you have is an anonymous, self-executing function.

the function is passed the jquery object (which is a function). e(".pic") is the same as $(".pic") or jQuery(".pic") because e is just a reference to jQuery.

2
  • Ok, so the first e is an object - most of times an event object; and the 2nd e is an abbreviation of jQuery or $. very nice! Thanks!
    – bcbishop
    Apr 3, 2014 at 0:52
  • 1
    there's no event, ignore Jack William's comment. the function has one argument, "e" and it's being passed "jQuery" (last line of code). Apr 3, 2014 at 0:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.