Is there any reason you would ever want to call a function defined inside a namespace created using the revealing module pattern using its fully qualified name? For example, A vs. B below?
var namespace = (function defineNamespace() {
function sayNoThankYou() { }
function callMeMaybe() {
sayNoThankYou();
}
return {
callMeMaybe: callMeMaybe,
sayNoThankYou: sayNoThankYou
};
}());
var namespace = (function defineNamespace() {
function sayNoThankYou() { }
function callMeMaybe() {
namespace.sayNoThankYou();
}
return {
callMeMaybe: callMeMaybe,
sayNoThankYou: sayNoThankYou
};
}());
There is only one difference between namespace.sayNoThankYou();
and sayNoThankYou();
in your example: the value of this
inside the sayNoThankYou
function. If you don't use this
inside the function, they are identical.