1

Possible Duplicate:
jslint requires “using strict” - what does this mean?

I keep getting errors about

Line 38: return (document.getElementById(a).innerHTML=b);
Missing "use strict" statement.

here

http://www.jshint.com/

I don't know to get rid of them or what they mean.

A prevous post suggest I user

"use strict";

and wrap all my code in a self-executing anonymous method..but this seemed a bit extrme...or maybe I just don't undersand javascript..is this what I should indeed do?

Community
  • 1
  • 1
  • It is best to edit and improve your original question instead of asking similar ones in quick sucession. – hugomg Nov 12 '11 at 22:12
  • So, even if it is legal, why do you insist on an assignment in a return statement? It doesn't make your code better, just harder to read and understand. – Ed S. Nov 12 '11 at 22:13

1 Answers1

0

You can read all about strict mode at the MDN documentation

Example:

function sum(a, a, c) // !!! syntax error
{
  "use strict";
  return a + b + c; // wrong if this code ran
}

Basically strict mode enables modern browsers to run additional checks on your code.

topek
  • 18,609
  • 3
  • 35
  • 43
  • This is a bug..that I can not define it globally. I'm not going to put it in each function...if jshint checks against strict...why does it even care if I set "use strict" –  Nov 12 '11 at 22:14
  • If you are annoyed by this warnings you can simply uncheck ' When code is not in strict mode' on the jsHint site. – topek Nov 12 '11 at 22:16
  • You can invoke strict mode on a entire script, see first section of the MDN docs – topek Nov 12 '11 at 22:17