Typos happen, and sometimes it is really hard to track them down in JavaScript. Take this for example (imagine it in between some more code):
// no error. I would like a warning
document.getElementById('out').innerHtml = "foo";
For undeclared variables, strict mode helps:
"use strict";
var myHTML = "foo";
myHtml = "bar"; // -> error
But it does not work for the example above. Is there a program or mode that can catch these bugs? I tried JSLint and JavaScript Lint, but they do not catch it.
And ideally, I would like this to still work (without warning):
// should work (without warning)
function MyClass(arg) {
this.myField = arg;
}