javascript - Access to object in module -


im doing logic parse json data object , want expose in module specific object outside other module can use, try following doesnt work,any other idea?

var jsonobject;  module.exports = {      parse: function () {     //here parsing     ....      jsonobject = json.parse(res)      ,     //here want expose outside     jsonobj:jsonobject     } 

if trying expose entire object, build other javascript object , use module.exports @ end :

myobj = function(){    this.somevar = 1234;    this.subfunction1 = function(){}; } module.exports = myobj; 

if want expose functions, don't need build object, , can export individual functions :

var somevar = 1234; subfunction1 = function(){}; nonexposedfunction = function(){}; module.exports = {    subfunction1:subfunction1,    somevar:somevar }; 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -