The first example defines a function in a global scope that can be called with init(). The second defines a property of an object with a name init, which is a function declaration on the right.
Typically, the second example provides a smaller area in which you could perform this function.
The first example allows you to call this function:
init();
And second, more likely the following:
var thing = function() {
init: function() { }
};
thing.init();
source
share