1

Can someone explain me which bracket here is used for what?

let myModule = (function() {})();

i know that the inner part = function() { // Some stuff here } is a function, so what does

(innerpart)();

? How and why is it different from

let myModule = function() {}

1 Answers1

2

when you declare do:

let foo = function () {}

you're just declaring a function foo

when you do:

let foo = (function() {})();

edited: thanks to @VLAZ

you're declaring a function foo and calling it right away. It's the same as:

let f = function() {} 
let foo = f()
Lucas Dolsan
  • 185
  • 2
  • 13