在 Node.js 中使用某些 es6 方法时是不是需要使用 strict [重复]
Posted
技术标签:
【中文标题】在 Node.js 中使用某些 es6 方法时是不是需要使用 strict [重复]【英文标题】:Is it necessary to use strict when using certain es6 methods in Node.js [duplicate]在 Node.js 中使用某些 es6 方法时是否需要使用 strict [重复] 【发布时间】:2016-12-24 14:47:36 【问题描述】:我们在我的工作中进行了辩论,有人说在使用 es6 和 nodejs 时,当然没有 babel,你应该总是添加 'use strict' ,因为某些 es6 方法可能不起作用。我找不到支持这一点的文档,是真的吗?
【问题讨论】:
您是在询问是否默认启用严格模式,还是因为您使用的是 es6?不,不是。 已回复 here 和 here 【参考方案1】:根据规范:
模块代码始终是严格模式代码。
http://www.ecma-international.org/ecma-262/6.0/#sec-strict-mode-code
【讨论】:
以上是关于在 Node.js 中使用某些 es6 方法时是不是需要使用 strict [重复]的主要内容,如果未能解决你的问题,请参考以下文章
使用 ES6 模块时 Node.js 中 __dirname 的替代方案