2

I am intermediate JavaScript developer and I have a question regarding the following IIFE construction:

   var myModule = (function () {

   })(this);

I see a lot of frameworks using this approach but it doesn't make sense for me the reason of the "this" object being passed to the invoked function. What is the goal of the "this" object passed to the function, once the function doesn't declare any arguments to be received?

Jonatan Cloutier
  • 899
  • 9
  • 26
mhenley
  • 69
  • 1
  • 6
  • Well I guess you can still access it as `arguments[0]` but I don't see why you'd not give it a parameter name if you're bothering to pass it – Paul S. Oct 04 '14 at 01:37
  • If you see *"a lot of frameworks"* do this, then please give us a few examples. There's no point to it as written. –  Oct 04 '14 at 01:52

0 Answers0