I still a bit confused with those Immediate Invoked Function Expression. I got the scope closure (I've read Crockford's book), but then @plalx kindly wrote me this example for another doubt i had (jsfiddle linked at the end) using IIFE. And that made a bit confused again, here how I'm thinking.
In Java one would think:
type doSome(type input){
do_stuff
return same type
};
then later
doSome(data);
so in js I could do just the same, right?
function doSome(input){
do_stuff;
return someThing;
}
and latter:
doSome(data);
or with an IIFE much more used:
var doSome = (function(data){
do_stuff;
return something
})();
and latter:
doSome(data);
Am I correct so far?
So my question is: Why use IIFE instead of the other way in this case? both codes that raised this doubt are in jsfiddle: