Jshint.com requires "use strict". What does this mean?

user656925 picture user656925 · Nov 12, 2011 · Viewed 55.7k times · Source

Jshint.com is giving the error:

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

Answer

Czarek Tomczak picture Czarek Tomczak · Nov 12, 2011

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) 
{

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

What does "use strict" do in JavaScript, and what is the reasoning behind it?

UPDATE.

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 thinks this is wrong.

"use strict";    
function asd()
{
}

But there is nothing wrong with it...

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

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

Then it says:

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