0

Why if I have

function(){...}()

does not work while when I put inside brackets like

(function(){...}())

it works?

Alex
  • 4,631
  • 7
  • 30
  • 44
  • 2
    The first is a function declaration which is a statement. The second is a function expression. Only the value that an expression produces can be executed. – VLAZ Sep 15 '20 at 06:53
  • Also relevant: [How does the (function() {})() construct work and why do people use it?](https://stackoverflow.com/q/1639180) | [var functionName = function() {} vs function functionName() {}](https://stackoverflow.com/q/336859) – VLAZ Sep 15 '20 at 06:54

0 Answers0