How to call a javascript function inside another function -


i have this:

var yournamespace = {      foo: function() {         .....     },      bar: function() {         function foobar() {....         }     } }; 

is there possibility call inside of foo, foobar function inside of bar?

with exact structure cannot can :

var yournamespace = {    foo: function() {         .....          yournamespace.foobar()     },     bar: function() {        function foobar() {....}        yournamespace.foobar = foobar;     } }; 

or nicer, (imo) :

var yournamespace = {    foo: function() {         .....          yournamespace.bar.foobar()     },     bar: function() {        yournamespace.bar.foobar =  function() {....}      } }; 

please note: in both case, bar() must run before foo() otherwise foobar undefined


Comments