title: Set a callback function inside a javascript class
body: <p>excuse the pseudo code, my actual file is much larger:/</p>
  
  <p>I want to call a function (with parameters) from inside a class. However, that function should be passed to the class as a variable.</p>
  
  <pre><code>someObject = {
      itWorked:function(answer){
         alert(answer);
      },
  
      plugins:{
          somePlugin:function(){
  
              var callback;
              this.doSomething = doSomething;
  
              function setCallback(c){
                  callback = c;
              }
  
              function doSomething(){
                   var answer = "hello";
                   [callback](answer); // how do I call this?
              }
  
          }
      },
  
      widgets:{
          something:function(){
              var doIt = new someObject();
              doIt.setCallback(someObject.itWorked()); // how do I send this?
              doIt.doSomething();
          }
      }
  }
  </code></pre>
  
  <p>So how would I pass <code>itWorked()</code> to the class?
  And how would I call that <code>itWorked(answer)</code> function within the class as well as passing a variable to if?</p>