Recently, I ran some of my JavaScript code through Crockford's JSLint , and it gave the following error:(最近,我通过Crockford的JSLint运行了一些JavaScript代码,并给出了以下错误:)
Problem at line 1 character 1: Missing "use strict" statement.(第1行第1个字符处的问题:缺少“使用严格”语句。)
Doing some searching, I realized that some people add "use strict";
(进行搜索后,我发现有些人添加了"use strict";
) into their JavaScript code.(纳入他们的JavaScript代码。) Once I added the statement, the error stopped appearing.(添加语句后,错误停止出现。) Unfortunately, Google did not reveal much of the history behind this string statement.(不幸的是,谷歌没有透露此字符串语句背后的许多历史。) Certainly it must have something to do with how the JavaScript is interpreted by the browser, but I have no idea what the effect would be.(当然,它一定与浏览器如何解释JavaScript有关,但是我不知道会有什么影响。)
So what is "use strict";
(那么什么是"use strict";
) all about, what does it imply, and is it still relevant?(所有的一切,这意味着什么,并且仍然有意义?)
Do any of the current browsers respond to the "use strict";
(当前的浏览器是否响应"use strict";
) string or is it for future use?(字符串还是将来使用?)
ask by Mark Rogers translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…