Jshint.com要求“使用严格”。这是什么意思? [英] Jshint.com requires "use strict". What does this mean?

查看:76
本文介绍了Jshint.com要求“使用严格”。这是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jshint.com提供错误:

Jshint.com is giving the error:


第36行:var signin_found;缺少使用严格声明。

Line 36: var signin_found; Missing "use strict" statement.


推荐答案

在您的顶部添加use strict js文件(在.js文件的第1行):

Add "use strict" at the top of your js file (at line 1 of your .js file):

"use strict";
...
function initialize_page()
{
    var signin_found;
    /*Used to determine which page is loaded / reloaded*/
    signin_found=document.getElementById('signin_button');
    if(signin_found) 
{

更多关于use strict的信息有关stackoverflow的问题:

More about "use strict" in another question here on stackoverflow:

什么是使用严格在JavaScript中做什么,背后的原因是什么?

UPDATE。

有jshint.com有问题,它要求你在每个函数中加入use strict,但是应该允许它为每个文件设置全局。

There is something wrong with jshint.com, it requires you to put "use strict" inside each function, but it should be allowed to set it globally for each file.

jshint。 com认为这是错误的。

jshint.com thinks this is wrong.

"use strict";    
function asd()
{
}

但是有没问题...

它希望你对每个函数都使用use strict:

It wants you to put "use strict" to each function:

function asd()
{
    "use strict";
}
function blabla()
{
    "use strict";
}

然后它说:


干得好! JSHint没有发现您的代码有任何问题。

Good job! JSHint hasn't found any problems with your code.

这篇关于Jshint.com要求“使用严格”。这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆