Can you explain the reasoning behind the syntax for encapsulated anonymous functions in JavaScript? Why does this work: (function(){})(); but
(function(){})();
You can also use it like:
! function() { console.log('yeah') }()
or
!! function() { console.log('yeah') }()
! - negation op converts the fn definition to fn expression, therefore, you can invoke it immediately with (). Same as using 0,fn def or void fn def
!
()
0,fn def
void fn def