(function( skillet, $ ) {
//Private Property
var isHot = true;
//Public Property
skillet.ingredient = "Bacon Strips";
//Public Method
skillet.fry = function() {
var oliveOil;
addItem( "\t\n Butter \n\t" );
addItem( oliveOil );
console.log( "Frying " + skillet.ingredient );
};
//Private Method
function addItem( item ) {
if ( item !== undefined ) {
console.log( "Adding " + $.trim(item) );
}
}
}( window.skillet = window.skillet || {}, jQuery ));
What’s really cool is that you can now extend the namespace using the exact same syntax.
Feelin’ it - thanks Jaco. Also good to read through Thoughtbot’s Blog Post, though their final example is not self-passing, so you can’t extend the module later on.