Benefits of “Use Strict” in JS
本问题已经有最佳答案,请猛点这里访问。
除了防止错误编码之外,
严格模式有无数的好处,但由于您特别询问了性能,而不仅仅是良好的编码好处,MDN对此有何看法:
Strict mode makes several changes to normal JavaScript semantics.
First, strict mode eliminates some JavaScript silent errors by
changing them to throw errors. Second, strict mode 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. Third, strict mode prohibits some syntax
likely to be defined in future versions of ECMAScript.
因此,正如您所要求的,根据MDN的Firefox人员所说,严格的模式代码有时可以运行得更快。
有关严格模式的一般好处,请参见"使用严格"在JavaScript中做了什么,以及它背后的推理是什么?
好处如下:)
请在这里查看有关在JavaScript中严格使用的更好解释。