Hi,
I'm trying to understand why JSLint complains about an implied global variable in the following example:
var TEST = (function () {
var count = 0;
function get_count() {
return add_one();
}
function add_one() {
count += 1;
return count;
}
return {
get_count: get_count
};
}());
Running this through JSLint gives the error:
Problem at line 5 character 12: 'add_one' is not defined.
As well as saying:
Implied global: add_one 5
If you move the add_one()
function before the get_count()
function the error goes away. However with the code as it is above, it doesn't produce any errors when you run it in the browser. Can anyone explain why JSLint is complaining?
Thanks!
Matt