title: JavaScript Objects and Scope
body: <p>I have some JavaScript that looks like this:</p>
  
  <pre><code>define(function(require, exports, module) {
      // Constructor function for our ContentView class
      var OtherObject = require('OtherObject');
  
      function MyObject() {
          this.currentThing = null;
  
          setThing();
          var b = new OtherObject(moving);
      }
  
      function setThing() {
          this.currentThing = "A string!";
      }
  
      function moving() {
          console.log(this.currentThing);        
      }
  
      module.exports = MyObject;
  });
  </code></pre>
  
  <p>And an object in another file that looks like this:</p>
  
  <pre><code>define(function(require, exports, module) {
      // Constructor function for our ContentView class
      function OtherObject(callback) {
          this.whatever = null;
  
          callback();
      }
  
      module.exports = OtherObject;
  });
  </code></pre>
  
  <p>I want to let the OtherObject use a callback when something happens internally, and have that callback access an object instantiated in the MyObject file. However, whenever moving() is called, this.currentThing is undefined. I'm probably overlooking something obvious here, but I'd love some help!</p>