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

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -