Eliminates some JavaScript silent errors by changing them to throw errors.
Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that’s not strict mode.
Prohibits some syntax likely to be defined in future versions of ECMAScript.
When the JS engine needs to execute the code, the engine parses it to give the developer advantages. This parsing happens when execution context (function) is invoked, not declared.
'use strict;
function myFunc(){
x = 1;
console.log(x);
}
exports = {..}
In a typical server.js file, we don’t invoke the sever.js as a module. Instead of a product event like onTicketCreate only invokes the handler - onTicketCreateHandler().
onTicketCreateHandler()'s execution context should have "use strict"; statement declared for the JS Engine to drive advantages of it in the current function definition.
Usually, it’s simply onTicketCreateHandler() invokes and references to function or variable declarations out side of exports = {}. JS Engine further executes these functions. In above example myFunc() definition.
Nowhere server.js is treated as an execution context in itself. Usually, node applications organize files in terms of modules and import them – where each module is treated as execution context.