I am watching a video course on Google Maps which has the following code in a script.js
file which is referenced from within the <head>
tag of the index.html
file:
(function(window, google) {
// code not shown sets element and
// options (center, zoom, disableDefaultUI).
map = new google.maps.Map(element, options);
}(window, google))
Based on this SO question, as well as the IIFE pattern, I was expecting the outer parentheses to be enveloping the function only, not the argument list, like so:
(function(window, google) {
// same exact code here as shown above.
})(window, google)
I tried both and they both work and display the map. I have not been able to find a reference to the first, envelope-everything approach. Is it just a minor variation of the same pattern?