Using Named Immediately-Invoked Function Expression (IIFE) instead of comments
问题 What are the pros and cons of utilizing Named IIFEs within JS code to describe and group related code? I've been using this "pattern" to lend structure to my more procedural code that gets executed only in one place. Example (function hideStuffOnInstantiaton(){ $('oneThing').hide().removeClass(); $('#somethign_else').slideUp(); $('.foo').fadeOut(); }()); I find this preferable to both: // hide Stuff on Instantiaton $('oneThing').hide().removeClass(); $('#somethign_else').slideUp(); $('.foo')