title: Why is my variable undefined inside the Underscore.js each function?
body: <p>Here is my code:</p>
  
  <pre><code>TextClass = function () {
      this._textArr = {};
  };
  
  TextClass.prototype = {
      SetTexts: function (texts) {
          for (var i = 0; i &lt; texts.length; i++) {
              this._textArr[texts[i].Key] = texts[i].Value;
          }
      },
      GetText: function (key) {
          var value = this._textArr[key];
          return String.IsNullOrEmpty(value) ? 'N/A' : value;
      }
  };
  </code></pre>
  
  <p>I'm using the Underscore.js library and would like to define my SetTexts function like this:</p>
  
  <pre><code>_.each(texts, function (text) {
      this._textArr[text.Key] = text.Value;
  });
  </code></pre>
  
  <p>but _textArr is undefined when I get into the loop.</p>