Link to home
Start Free TrialLog in
Avatar of Al4ddin2
Al4ddin2

asked on

how to call function inside object literal function

How do I call this.test inside this javascript structure?

var app = {
  init: function(){
      this.cache();
      this.bind();
  },
  cache: function(){
      this.test = function(){
          console.log("this");
      }
      console.log( "cache."  );
  },
  bind: function(){
      console.log( "bind."  );
  },
  doSomething: function(){
      console.log( "Simple app."  );
  }
}

app.init();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've requested that this question be closed as follows:

Accepted answer: 500 points for Kravimir's comment #a40968327

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
My solution demonstrated that Kravimir's assertion of "it can't be done" was incorrect.  My solution actually used the OP's original code, with a minor change for demonstrative purposes.