Is there a difference between:
(function(){ }).call(this);
and
(function(){ })();
or
var MODULE = {}; (function(){ this.hello = 'world' }).call(MODULE);
and
var MODULE = {}; (function(m){ m.hello = 'world' })(MODULE);
I often see the first case in compiled javascript. They both create a scope and do a good job of expanding names.
Is there any difference or is it just a matter of taste.
Edit: And why will compiled javascript use a call through IIFE?
javascript scope namespaces
Jonathan de M.
source share