title: Javascript substr in Internet Explorer 8
body: <p>I get an error when running the following code using Internet Explorer 8:</p>
  
  <pre><code>for (var lang_elem in this.langElems) {
      if (this.langElems.hasOwnProperty(lang_elem)) {  // ignore attributes down the prototype chain
          var www1 = this.langElems[lang_elem].length;
          var xxx1 = line.substr(0, www1);
          var yyy1 = this.langElems[lang_elem];
  
          if (xxx1 == yyy1) {
              elem_type = lang_elem;
              break;
          }
      }
  }
  </code></pre>
  
  <p>The Debugger stops in the line where xx1 is defined (I obviously defined these three variables for debug purposes) with the following message:</p>
  
  <p><em><strong>Unterbrechung bei JScript-Laufzeitfehler - Das Objekt unterstütz diese Eigenschaft oder Methode nicht.</em></strong></p>
  
  <p>which translates into</p>
  
  <p><em><strong>Break at JScript-runtime error - The object doesn't support the attribute or method.</em></strong></p>
  
  <p>I checked, but as to my knowledge, IE8 should support the substr-method. I call it with <strong><em>line.substr(0,2)</em></strong>, which should work (no negativ parameters).</p>
  
  <p>Does anyone have an idea why this error is shown?</p>