Answer the question
In order to leave comments, you need to log in
How does the use strict directive work?
Gentlemen, please tell me the mechanism of work of use sctrict and EcmaScript 5
If I understand correctly, you need to write according to the EcmaScript 5 standard only if you focus on browsers that support it (modern ones) and at the same time you need to declare the use strict directive.
The question is how a script written according to the EcmaScript 5 standard and the use strict directive will be executed when it is loaded from an EI 8 browser, for example. The script will be ignored by the browser and will not be executed?
Answer the question
In order to leave comments, you need to log in
Let's assume that we have developed the code using "use strict" and tested it in the Chrome browser. Everything works... However, the probability of errors in this case in IE9- has increased! He always works according to the old standard, which means that sometimes in a different way. The resulting errors will have to be debugged already in IE9-, and this is much less pleasant than in Chrome.
However, the problem is not so terrible. Few incompatibilities. And if you know them (and in the tutorial we will dwell on them) and write the correct code, then everything will be in order and "use strict" will become our faithful assistant.
"use strict";
. ECMAScript 5's strict mode is a way to opt in to a restricted variant of JavaScript. Strict mode isn't just a subset: it intentionally has different semantics from normal code. Browsers not supporting strict mode will run strict mode code with different behavior from browsers that do, so don't rely on strict mode without feature-testing for support for the relevant aspects of strict mode. Strict mode code and non-strict mode code can coexist, so scripts can opt into strict mode incrementally.
https://developer.mozilla.org/en-US/docs/Web/JavaS...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question