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?

bcbishop
  • 2,193
  • 3
  • 20
  • 23
  • 1
    There is no purpose, really. It's an abbreviation of 'event', and is used to refer to the local function. – Jack Apr 03 '14 at 00:32
  • 1
    @JackWilliams Pay a-bloody-ttention, all right? – Niet the Dark Absol Apr 03 '14 at 00: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 03 '14 at 00:54

2 Answers2

5

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

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
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.

Jeremy Danyow
  • 26,470
  • 12
  • 87
  • 133
  • 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 03 '14 at 00: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). – Jeremy Danyow Apr 03 '14 at 00:56