File 1
var M = function (speech) {
"use strict";
document.getElementById("speech").innerHTML = speech.toString();
};
File 2
$("#test").click(function () {
M("hello");
});
JS lint probelms v http://puu.sh/j8AOo/a24a88825b.png
File 1
var M = function (speech) {
"use strict";
document.getElementById("speech").innerHTML = speech.toString();
};
File 2
$("#test").click(function () {
M("hello");
});
JS lint probelms v http://puu.sh/j8AOo/a24a88825b.png
'M' was used before it was defined.
This error is because you're defining M
as a global variable in one file, and attempting to invoke it in another. Because global variables are often a sign of code-smell, JSLint makes you specifically declare them. There are a few options to do this. For one, you could prepend File 2
with /*global M*/
, and it should stop complaining.
Missing 'new'.
This is based on variable conventions. In JavaScript, we typically only name constructor functions using CamelCase. Because constructor functions are intended to be called with the new
keyword, it's detecting this as an error. In this case, your best option is probably to just rename M
to m
.
For more information on configuration and other JSLint
help topics, see this page. Alternatively, if you have any say at all in the matter, I would strongly suggest checking out JSHint instead.