3 ms·
Why did you wrap that in a closure / immediately invoked function expression?
by ghayes 10y ago
Why did you wrap that in a closure / immediately invoked function expression?
- wingless 10y agoIt's a way of hiding local variables. Old "var" variables are function scoped, so you can't even hide them in if-blocks or for-blocks, which makes scope leakage even worse. If you're a JS programmer you should definitely read Crockford's famous JS book, it explains a lot of JS patterns and the rationale behind them.