title: Node JS - TypeError: Cannot read property 'CONTEXT_1' of undefined
body: <p>Filename : orderManager.js</p>
  
  <pre><code>const notificationManager = require("./notificationManager");
  
  var orderManager = (function() {
  
      function orderManager() {
          console.log("orderManager");
      };
  
      orderManager.bootstrap = function() {
          console.log("orderManager.bootstrap");
          return new orderManager();
      };
  
      orderManager.prototype.orderContext = {
          "CONTEXT_1": "context_1",
          "CONTEXT_2": "context_2",
          "CONTEXT_3": "context_3"
      };
  
      orderManager.prototype.notify = function() {
          var dataObj = {};
          notificationManager.sendToClient(dataObj);
      };
  
      return orderManager;
  
  }());
  module.exports = orderManager.bootstrap();
  </code></pre>
  
  <p>Filename: notificationManager.js</p>
  
  <pre><code>const orderManager = require("./orderManager");
  
  var notificationManager = (function() {
  
      function notificationManager() {
          console.log("notificationManager");
      };
  
      notificationManager.bootstrap = function() {
          console.log("notificationManager.bootstrap");
          return new notificationManager();
      };
  
      notificationManager.prototype.sendToClient = function(dataObj) {
          console.log("notificationManager.prototype.sendToClient");
  
          var _this = this;
          switch (_this.request.body.orderContext) {
              case orderManager.orderContext.CONTEXT_1:
                  notifyClient(_this, dataObj);
                  break;
  
          }
      };
  
      return notificationManager;
  
  }());
  module.exports = notificationManager.bootstrap();
  </code></pre>
  
  <p>When i try to call <strong>notificationManager.sendToClient()</strong> function from <strong>orderManager.js</strong> file, that will give an error <strong>TypeError: Cannot read property 'CONTEXT_1' of undefined</strong>.</p>