4

I am reading a javascript file written by someone that has a couple of functions for modifying CSS and other things and I am not a pro level at Javascipt; I am seeing a piece of code like

    + function(a) {
    "use strict";

    function b() {
        var a = document.createElement("bootstrap"),
            b = {
                WebkitTransition: "webkitTransitionEnd",
                MozTransition: "transitionend",
                OTransition: "oTransitionEnd otransitionend",
                transition: "transitionend"
            };
        for (var c in b)
            if (void 0 !== a.style[c]) return {
                end: b[c]
            }
    }
    a.fn.emulateTransitionEnd = function(b) {
        var c = !1,
            d = this;
        a(this).one(a.support.transition.end, function() {
            c = !0
        });
        var e = function() {
            c || a(d).trigger(a.support.transition.end)
        };
        return setTimeout(e, b), this
    }, a(function() {
        a.support.transition = b()
    })
}(window.jQuery), + function(a) {

What does adding the + sign do to a javascript function ? The code is really long so I just pasted whatever i thought was relevant.

I have found my answer and this is a duplicate post of another but for those who want the full source code it is here source code

Bazinga777
  • 4,726
  • 13
  • 44
  • 76

2 Answers2

2

looking at this other question (JavaScript plus sign in front of function name) on the same subject, the following seems to be the answer:

It forces the parser to treat the part following the + as an expression. This is usually used for functions that are invoked immediately

source - https://stackoverflow.com/a/13341710/970847

Community
  • 1
  • 1
Dave Haigh
  • 3,919
  • 5
  • 30
  • 56
  • Thanks, I'll can read up on this now. I googled for answers but couldnt find an answer. So it is an IIFE; thats all. – Bazinga777 Aug 20 '14 at 11:39
  • 1
    Please [vote to close](https://stackoverflow.com/help/privileges/close-questions) the question as a duplicate (or flag it for mod attention), instead of posting the link as an answer. – Bergi Aug 20 '14 at 11:41
0

It forces the parser to treat the part following the + as an expression. This is usually used for functions that are invoked immediately.

From here JavaScript plus sign in front of function name

Community
  • 1
  • 1
Joanvo
  • 5,200
  • 2
  • 21
  • 34
  • Please [vote to close](https://stackoverflow.com/help/privileges/close-questions) the question as a duplicate (or flag it for mod attention), instead of posting the link as an answer. – Bergi Aug 20 '14 at 11:43