哪个ECMAScript 6功能意味着严格的模式? [英] Which ECMAScript 6 features imply strict mode?
问题描述
use strict
来触发严格模式,但这是不鼓励的。 ) 我明白,在ECMAScript 6中,某些语法功能将会打开严格模式,特别是 class
和模块(但是你这样做)。
在ECMAScript 6世界中,触发严格模式的完整方法是什么?
规格说:
- 模块代码是总是严格的模式代码。
- ClassDeclaration 或 ClassExpression 的所有部分都是严格的模式代码。
- ...
其余的只是ES5中已知的东西,基本上每个全局/ eval /函数代码以 使用严格;
指令。它在新的ES6功能类型(箭头,生成器,方法语法)中也起作用。
In ECMAScript 5 (aka JavaScript,) I can trigger strict mode by adding "use strict"
at the top of my function (or file, but this is discouraged.)
I understand that in ECMAScript 6, certain syntax features will turn on strict mode, especially class
, and modules (however you do those.)
In the ECMAScript 6 world, what is the complete list of ways to trigger strict mode?
The spec says:
- Module code is always strict mode code.
- All parts of a ClassDeclaration or a ClassExpression are strict mode code.
- …
The rest are just the known things from ES5, basically every global/eval/function code that begins with the "use strict";
directive. It does work within the new ES6 function kinds (arrow, generator, method syntax) as well.
这篇关于哪个ECMAScript 6功能意味着严格的模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!