[jQuery] Encapsulation Style
When writing plugins and such, what is your preferred style for
encapsulation? I know of two styles:
var PublicObject = function () {
// Private
function Function1() {
}
// Exposed
function Function2() {
}
return {
PublicMethod: Function2
};
} ();
-- OR --
(function () {
window.PublicObject = {
PublicMethod: Function2
};
// Private
function Function1() {
}
// Exposed
function Function2() {
}
})();