Passing arguments into the revealing Module pattern in Javascript -


how can pass arguments function when implementing revealing module pattern in javascript. have module this

var globalmodule = (function() {     function consolelog(texttooutput) {         console.log(texttooutput);     }      return {         consolelog: consolelog()     }; })(); 

later on, when run globalmodule.consolelog("dummy text");, undefined output.

do function inside return object

var globalmodule = (function() {    return {      consolelog: function(texttooutput)      {       console.log(texttooutput);      }    }  })();    globalmodule.consolelog("dummy text");

simply same output achieved . object => function call .no need return object

 var globalmodule ={          consolelog: function(texttooutput) {                                      console.log(texttooutput);                                    }        }        globalmodule.consolelog("dummy text");


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -