为什么严格模式的激活器 'use strict' 是一个字符串?

Why is strict mode's activator 'use strict' a string?

不要与想知道 use strict 的工作原理混淆,但为什么使用 'use strict';"use strict"; 激活严格模式而不是像 use strict; 这样的表达式?

use strict; 会在不支持严格模式的 JS 引擎中抛出错误。

使用字符串是向后兼容的。

我想答案很简单。正如我们所知,ECMAScript a.k.a javascript 直到现在都没有标准化。那为什么要串呢?这是因为所有浏览器都同意使用 'use strict'use strict 更可取。它还可以防止在不支持严格模式的旧浏览器上出错。