Re:Preparing Yourself for Modern JavaScript Development
by ufo on Friday July 06, 2012 @02:55PM
(#4209132)
IIFEs are cumbersome and non-intuitive. Better languages have block scope or a "let" statement instead.
Re:Preparing Yourself for Modern JavaScript Development
by grannyg00se on Friday July 06, 2012 @06:19PM
(#4209899)
Javascript [does/will]* have a "let" statement.
*depending on which version of ECMAscript is being used.
Re:Preparing Yourself for Modern JavaScript Development
by TazeTSchnitzel on Friday July 06, 2012 @06:09PM
(#4209875)
`let` is drafted for ECMAScript 6.
Re:Preparing Yourself for Modern JavaScript Development
by georgemcbay on Saturday July 07, 2012 @12:37AM
(#4210739)
...and ECMAScript 4 had block scope.
Language design by committee is seriously flawed and until a feature is shipping in all the major browsers it isn't real.
Re:Preparing Yourself for Modern JavaScript Development
by TazeTSchnitzel on Saturday July 07, 2012 @04:53AM
(#4211160)
ECMAScript 4 was cancelled.
Re:Preparing Yourself for Modern JavaScript Development
by georgemcbay on Saturday July 07, 2012 @02:08PM
(#4212276)
That was exactly my point.
I don't deride PHP (I don't know it), but I see nothing wrong with IIFE. Yes, it could benefit from some syntactic sugar, but otherwise it is just using one of the best features of JavaScript, function support (first-class functions, anonymous functions, etc.).
It makes perfect sense to use a pattern like IIFE in order to encapsulate code, often using closures to allow access in a controlled manner from the outside, etc.
I suppose perhaps you don't like closures and so forth, and that's fine, but many people including me love them.