JavaScript: Can ECMAScript 5's Strict Mode ("use strict") be enabled using single quotes ('use strict')?

Rudiger提出了一个问题:JavaScript: Can ECMAScript 5's Strict Mode (“use strict”) be enabled using single quotes ('use strict')?,或许与您遇到的问题类似。

回答者dan-gphFelix Kling给出了该问题的处理方式:

For you, without using a browser that supports strict mode:

A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either the exact character sequences "use strict" or 'use strict'. A Use Strict Directive may not contain an EscapeSequence or LineContinuation.

希望本文对你有帮助,欢迎支持JavaScript中文网