javascript - Why does a function in my object return undefined? -


consider code:

var mse = {     module : {} };  mse.module = (function() {      'use-strict';      var app = {          tabspre : function() {              var tabspre = {                 init : function() {                  },                 changetab : function(arg) {                     return arg;                 }             };              tabspre.init();             return tabspre;         }     };      return app;  })();  console.log( mse.module.tabspre() ); console.log( mse.module.tabspre().changetab() ); // undefined console.log( mse.module.tabspre.changetab() ); // uncaught typeerror: mse.module.tabspre.changetab not function 

i trying access changetab() in tabspre object, don't seem able to. last 2 console.log statements aren't giving me had hoped for. how can this?

here's jsfiddle: https://jsfiddle.net/xhb16ql6/

in first console.log, can see function there:

enter image description here

any or guidance on i'm doing wrong great. i'm having dumb day , can't see it.

thanks, mikey

changetab return args passed , print undefined because didn't pass arguments, try:

console.log(mse.module.tabspre().changetab("args"))  //"args" 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -