What's the difference following two cases?
Using use strict
at the top of the file, not in a function
"use strict";
(function () {
// ...
})();
Using use strict
in the wrapping function
(function () {
"use strict";
// ...
})();
I read in a blog post that putting use strict
at the top of the file (not in a function) could have unforeseen effects.
Also, from what I remember jshint
recommends putting it into a function too.
So, why is it better to have it into a function instead of putting it in the top of the file?