vendredi 14 avril 2017

Passing arguments into the revealing Module pattern in Javascript

How can you pass arguments to a function when implementing the Revealing module pattern in JavaScript. I have a module like this

var GlobalModule = (function() {
    function consoleLog(textToOutput) {
        console.log(textToOutput);
    }

    return {
        consoleLog: consoleLog()
    };
})();

Later on, when i run GlobalModule.consoleLog("Dummy text");, I get undefined as the output.

Aucun commentaire:

Enregistrer un commentaire