Can someone explain in detail what this snippet of js does?
(function (window) {
var test = window['test'] = {};
test.utils = new(function(){ ... })();
})(window);
I understand that the function is not globally scoped. I understand that it is creating a variable called test that points to a property in the window
object that is an empty object. I also understand that utils
is a property of test.
I don't understand what the purpose of the last part is (window);
or why the utils
function is being designated as new
.
Please explain.