title: assigning object to prototype
body: <p>I am trying to assign a object to a prototype, but I keep getting a error that the object is undefined. I am trying to do this</p>
  
  <pre><code>//x.prototype.y = {};
  StreetEasy.prototype.neighborhoodPaths = {};
  </code></pre>
  
  <p>and at a later point in the code I am trying to access this object in another prototype function and push in new data with</p>
  
  <pre><code>//x.prototype.assignData = function(z, a){
    // this.y[z] = a;
  //}
  StreetEasy.prototype.findNeighborhoodPath = function(areaQuery, callback){
    var data = {q: areaQuery, key: this.apiKey, format: this.format};
    var query = qs.stringify(data);
    var url = AreaSearchUrl + '?' + query;
  
    var areaQ = areaQuery.toLowerCase();
    if (this.neighborhoodPaths[areaQ]) {
        callback(this.neighborhoodPaths[areaQ].path);
     } else {
        http.get(url, function(response){
          response.setEncoding('utf8');
          response.on('data', function (rData){
            rData = JSON.parse(rData);
            callback(rData);
            rData.areas.every(function(element){
      -----------error is here-&gt; this.neighborhoodPaths[element.name.toLowerCase()].path = element.path;
            });
  
          }).on('error', function(e){
                 console.error('ERROR: ' + e.message + ' | ' + e.statusCode );
        });
      });
    }
  };
  </code></pre>
  
  <p>Node keeps returning </p>
  
  <p>TypeError: Cannot read property z of undefined. What am I doing wrong?</p>
  
  <p>Edit more of the code:</p>
  
  <pre><code>StreetEasy.prototype.neighborhoodPaths = {}; 
  StreetEasy.prototype.findNeighborhoodPath = function(areaQuery, callback){
    var data = {q: areaQuery, key: this.apiKey, format: this.format};
    var query = qs.stringify(data);
    var url = AreaSearchUrl + '?' + query;
  
    var areaQ = areaQuery.toLowerCase();
    if (this.neighborhoodPaths[areaQ]) {
        callback(this.neighborhoodPaths[areaQ].path);
     } else {
        http.get(url, function(response){
          response.setEncoding('utf8');
          response.on('data', function (rData){
            rData = JSON.parse(rData);
            callback(rData);
            rData.areas.every(function(element){
      -----------error is here-&gt; this.neighborhoodPaths[element.name.toLowerCase()].path = element.path;
            });
  
          }).on('error', function(e){
                 console.error('ERROR: ' + e.message + ' | ' + e.statusCode );
        });
      });
    }
  };
  </code></pre>