In this example code:
(function(){
var obj = function() {
};
obj.prototype.hello = function(){
console.log('Hello World!');
};
})();
I see a lot of libraries doing this. Why is wrapping your code in an Immediately Invoked Function Expression (IIFE) a good practice? And how do I access this object outside, like jquery does?
Because if I do something like this:
var test = new obj();
The browser displays that obj is undefined.