且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Javascript:除了“use strict”之外,其他“使用”有指令吗?

更新时间:2023-12-06 08:08:16

可以在指令序言(JavaScript引擎可能使用的部分)中的更多示例:

Some more examples that can be in the "directive prologue" (a section potentially usable by JavaScript engines):


  • 'use strict';

  • 'use asm';

    Mozilla的 asm.js 是该语言的一个子集,适用于对于数字运算。

  • '使用更严格';

    Google的SoundScript。对于快速OOP

    还有一些模式,如:

    • 'use strict';
    • 'use asm';
      Mozilla's asm.js is a subset of the language, geared towards crunching numbers.
    • 'use stricter';
      Google's SoundScript. For fast OOP
      Has also some modes like:
      • 'use stricter+types';
      • http://www.2ality.com/2015/02/soundscript.html

      推文 Jeremy Ashkenas 建议进一步使用 + - 前缀相同'使用...'; 字符串('使用更严格+ types -tco + jsx + asm + es2019-pre'; ),但这似乎与规范(在 kangax的答案中进一步澄清, Bergi的回答)。

      A tweet by Jeremy Ashkenas suggests some further use of + and - prefixes in the same 'use ...'; string ('use stricter +types -tco +jsx +asm +es2019-pre';), but that seems to contradict the spec (further clarified in kangax's answer and Bergi's answer).