I see IIFE's all the time.
I see a series of statements that are left open, i.e, they are not encapsulated by brackets.
Why have I not seen a function followed by its invocation
// lib code...we are inside an IIFE
function fooName () {
}
fooName();
// lib code...
to immediately invoke a series of statements when you don't need closure, i.e. you don't need persistent or static local variables?
Is there something wrong with this idiom/pattern? Does it have name? Is it used?
Non - "small" code
function manageGlobal() {
if (win.$A && win.$A.cg) {
$A.extend($A, window.$A);
} else if (window.$A) {
$A_previous = window.$A;
} else {
$A = window.$A = {};
}
}
manageGlobal();
This is just a function declaration followed by its call.
It has no name as it has no specificity : it's just basic obvious use of the language.
By the way, it has no advantage over an IIFE :
If you don't need a closure, and don't need to avoid namespace polluting as you're in a small IIFE, then you may just directly include the code you have in your function instead of declaring it.