Skip to main content
2 of 3
added 16 characters in body
laycat
  • 5.7k
  • 8
  • 36
  • 47

this maybe a little late however my understanding of the asker's question is such that

how does this magic work:

(function(){}) ('input') // utilised in his example 

I maybe wrong however the usual practice that people are familiar with is

(function(){}('input') ) 

the reason is such that javascript parentheses aka (), can't contain statements and when the parser encounters the function keyword, it knows to parse it as a function expression and not a function declaration.

source: http://benalman.com/news/2010/11/immediately-invoked-function-expression/

laycat
  • 5.7k
  • 8
  • 36
  • 47