It makes no sense for the specific design that you are showing here. The reason for using IIFE in this type of construct is when you have static data that needs to be declared, want to be available to your object, but don't want it to be publicly available or interfere with the global namespace or be an instance of data.
Since the code that you show does not show any of them, it does not offer any advantages, as you showed. But if there were any other variables declared outside the object, but inside IIFE, then IIFE would protect and close them and isolate them from the outside world.
For example, if you have this:
Visualizer = (function() { var counter = 0; function Visualizer() { counter++; ... } Visualizer.prototype.getCount = function () { return counter; } ... return Visualizer; })(); var viz = new Visualizer();
Then IIFE will include the counter variable, which will be accessible to all methods of all Visualizer instances, but isolated from the outside world, and IIFE will offer some potential benefits.
source share