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:
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
Post a Comment