Hello! Explain, please, the functional expression on the topic "closures, scope":

 return function () {
         alert (x);
       }; 

})(i); </pre>

To create a function, you need to declare it, in curly brackets, what it does is described: return function () {code} (i). How to understand the variable i in brackets at the end?

  • 2
    show all the code - Igor
  • @Pavel Timofeev The function declaration is enclosed in parentheses to get the expression of the function, and this postfix expression is called with an argument i. That is, the function is declared and immediately called. - Vlad from Moscow

0