4 ms·
If you happen to write var foo = 'bar', baz = 'bletch' (function (global) { //module pattern code here ... })(this); then you have trouble. Se
by BrendanEich 12y ago
If you happen to write
var foo = 'bar',
baz = 'bletch'
(function (global) {
//module pattern code here ...
})(this);
then you have trouble. Semicolons are not optional (meaning always optional, you can leave them out at will). Please read my blog post.
- jedschmidt 12y agoI wish `void` would get more love for IIFEs instead of just sitting there in a dark corner of JS, unloved. var foo = 'bar' var baz = 'bletch' void function (global) { //module pattern code here ... })(this)
- Havvy 12y agoAlmost perfect, but you left an unmatched close parenthesis before the call operator.
- mavdi 12y agoThis is a good example! It will try to run 'bletch' as a function. awesome.
- ttty 12y agoWho still writes this in 2015? Now is: module.exports = function(){};