Argument passing into IIFE

Viewed 524

Do anyone can explain and prove which one of examples is "more correct"?

A: pass object as an argument

(function($){
    $.doStuff();
})(jQuery);

B: retrieve object within the function

(function(){
    var $ = jQuery;
    $.doStuff();
})();

I really like B because of its readability. Only technical difference between A and B is that B has to lookup one more scope. I consider this as marginal difference so why is "recomended" the A way?

Note that the jQuery is just example. Important is the nature of the problem: Pass as argument or retrieve within the function?

2 Answers
Related