I am using the following namespacing pattern:
var MyNamespace = new function () {
var foo = function () {
bar();
};
var bar = function () {
alert("bar");
};
this.init = function () {
foo();
};
};
$(document).ready(function() {
MyNamespace.init();
});
JSLint complains that bar
is used before it's defined. However foo
is not called until after bar
has been declared. The code works fine with all the browsers I have tried: http://jsfiddle.net/jDKvz/
The pattern is per How do I declare a namespace in JavaScript?, second answer.
Do I need to fix something here, or should I just ignore JSLint?