gpt4 book ai didi

javascript - ECMAScript 多个 Prologue 指令

转载 作者:行者123 更新时间:2023-11-29 14:57:56 29 4
gpt4 key购买 nike

某些 ECMAScript 环境允许通过 Directive Prologue 切换到特殊模式。 ECMAScript 5 有“使用严格”和其他如 asm有自己喜欢的“使用asm”。

Directive Prologues 上的文档是用一种对我的理解水平来说有点迟钝的语言编写的。构建具有多个指令的指令序言的正确方法是什么?我的预感是:

function(){
"use foo";
"use bar";
}

但我不确定。

最佳答案

What is the correct way to construct a Directive Prologue with multiple Directives?



作为 spec you linked说,

a Directive Prologue is the longest sequence of ExpressionStatement productions occurring [at the begin of a script or function] and where each [of them] consists entirely of a StringLiteral.



因此,您可以将它们串在一起,这些字符串文字语句中的每一个都是指令;并且可以具有特定于实现的含义(仅指定了 Use-Strict-Directive)。你的预感是正确的,这应该有效:
"use bar"
"use strict"; 'use x';
'use foo';

关于javascript - ECMAScript 多个 Prologue 指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14902465/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com