JavaScript Module Pattern in IIFF

JavaScript Module Pattern in Immediately-Invoked-Function-Expressions

by rsschouwenaar

JavaScript

// Module pattern
var DocumentIsReady = (function() {
    var documentReady = {};

    documentReady.isReady = function(value) {
        if(value) {
        		console.log('True');
            return true;
        } else {
        		console.log('False');
            return false;
        }
    }

    return documentReady;
})();

(function(window, document, documentReady, undefined) {

	documentReady.isReady(true);

})(window, document, DocumentIsReady);

DocumentIsReady.isReady(false);