What is the difference between:
(function () {'use strict';})();
and "use strict"
.
I don't understand when or why I would use one over the other?
I think that one declares the complete external JS document strict and the other makes a function strict.
My confusion comes when I see people enclose their complete external JavaScript in:
(function () {'use strict';})();
Why not just start the document with use "use strict"
?
Lastly, I have tested an external JS doc using the same code.
One, I used "use strict"
and it worked.
The other I enclosed the complete JS document with (function () {'use strict';})();
and it did not work.
Why?
JavaScript is my first programming language and I am a little overwhelmed by its depth. I really appreciate your patience and professional guidance thank you for any help or direction you can offer me.
Thank you so much.