Reputation: 2334
When including 'use strict';
at the beginning of a JavaScript file which is included in an HTML page, would any subsequent included files or JS adhere to the Strict Mode ruling established in the first file? Or would Strict Mode be isolated to the first file?
Example:
<script src="/path/to/file_using_use_strict.js"></script>
<script src="/path/to/file_omitting_use_strict.js"></script>
<script>
console.log('Hello! Am I strict?');
</script>
I checked the MDN documentation, but couldn't find an example outlining this specific situation. Thanks!
Upvotes: 0
Views: 153
Reputation: 15130
From the Strict mode MDN web docs:
Strict mode applies to entire scripts or to individual functions.
So the answer to your question is yes, strict mode only applies to the scripts or functions where you invoke it.
Upvotes: 3