I have a doubt regarding one of the answers at this link
Do you recommend using semicolons after every statement in JavaScript?
I am providing the particular answer that I need clarification on:
An ambiguous case that breaks in the absence of a semicolon:
// define a function var fn = function () { //... } // semicolon missing at this line // then execute some code inside a closure (function () { //... })();
This will be interpreted as:
var fn = function () { //... }(function () { //... })();
We end up passing the second function as an argument to the first function and then trying to call the result of the first function call as a function. The second function will fail with a "... is not a function" error at runtime.
My doubt is that how come the second function became the argument of the first function? Because for all I know
function myFunc(/*argument goes here*/){}
And not after the {}
.
Can someone explicitly explain which ones are the functions and their respective arguments?