Javascript why wrap a variable or constructor in an IIFE?
问题 I saw something like this today var Visualizer = (function() { function Visualizer() { //... } Visualizer.prototype.function1 = function () { /* ... */ } //... return Visualizer; })(); var viz = new Visualizer(); I don't understand the point of this versus just getting rid of the iife wrapper. 回答1: There's no point for the specific construct that you show here. The reason to use an IIFE in this type of construct is when you have static data that you need to declare, want to be available to