I have come across the following discussions:
Exploring the advantages of enveloping angular controller/service/factory declarations in an anonymous function
Analyzing the benefits of wrapping an angular javascript file with "(function() { ....[js code here]...... })();"
However, none directly address my query. In the context of wrapping JavaScript in IIFE blocks, two common patterns can be observed:
(function (window, angular, undefined) {
'use strict';
angular.doSomething();
// more code here
})(window, window.angular);
and also this:
(function () {
'use strict';
angular.doSomething();
// more code here
})();
While it is evident that 'angular' is globally defined, I am curious about the advantages and disadvantages of the first approach over the second. Since JavaScript passes 'angular' by reference regardless, are there any performance improvements, scope security enhancements, or is it primarily beneficial for code minification?