JSLint does not like this code saying "'b' was used before it was defined"
var a = function () {
b();
},
b = function () {
alert("Hello, world!");
};
a();
but perfectly happy with this
var a, b;
a = function () {
b();
};
b = function () {
alert("Hello, world!");
};
a();
But I am not defining anything in my second code snippet. I am merely declaring variable b.
So why is JSLint doing this? Is there a reason I should be declaring all my functions first?
PS I understand I could have just changed order of a and b, but in real project my functions are event handlers and sometimes they call each other, so it is probably not possible.