Why is "using strict" still a string literal?

Why do we still need to use the quoted string literal to include strict in JS? Of course, here one could use something stronger “typed”, for example, call a built-in function, for example, Object.UseStrict() or something like that. What is the reason for having to resort to a string literal?

+6
source share
1 answer

Compatibility in all browsers and JS systems.

For example, http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/

No new syntax is introduced to enable strict mode. This is huge. This means that you can enable strict mode in your scripts - today - and in the worst case, it will not have side effects in older browsers.

+13
source

Source: https://habr.com/ru/post/979518/


All Articles