Bootstrap Function Declaration

I was looking at the original JS source source, and I came across something I had not seen before:

+function ($) { "use strict"; //... }(window.jQuery); 

What is the deal with + before declaring a function? Is this a mitigation of some potential mineralization problems or something else?

I believe that placing the + character in front of the type of expression converts the result of the expression into a number, but I do not see how significant this will be here.

Thanks for anyone who can shed light on this for me.

+7
javascript twitter-bootstrap iife
source share
1 answer

This means that a function declaration is an expression of a function, so that it can be executed immediately.

This is usually done by placing parentheses in it:

 (function ($) { "use strict"; //... }(window.jQuery)); 

or

 (function ($) { "use strict"; //... })(window.jQuery); 
+8
source share

All Articles