I have one very simply question to ask:
Is it a good practice to wrap code inside an IIFE whenever I intend on using "use strict
" ?
Now, I do understand the usefulness of Scope Closure (answered here and here) or probably better yet, the usefulness of the ever-so-prevelant module approach to design and why IIFE is such a powerful tool to be used (not only) in these scenarios, but that's not what this question is about.
What I've noticed, most linters (jsfiddle included) do tend to complain whenever you want to use strict mode in the global scope:
Wrapping the block inside IIFE seems to stop the linter from complaining
(function(){
"use strict";
console.log("I compiled!");
})();
Is there any basis as to why should use strict;
be kept inside IIFE, or is this just a "baseless objection" raised with no proper reason behind it?