title: Why does the statement if ( !condition ) { console.log(condition) } display true
body: <p>I want to make a String method, which accepts a RegExp and a callback, then splits String by RegExp, and inserts callback's return in split array. In short, it would do something like this:</p>
  
  <pre><code>"a 1 b 2 c".method(/\d/, function ($1) { return $1 + 1; })
      =&gt; [a, 2, b, 3, c]
  </code></pre>
  
  <p>In case the String doesn't match the RegExp, it should return an array, like this:</p>
  
  <pre><code>"a b c d e".method(/\d/, function ($1) { return $1 + 1; })
      =&gt; ["a b c d e"]
  </code></pre>
  
  <p>I wrote this code, but it doesn't work as I thought:</p>
  
  <pre><code>String.prototype.preserveSplitReg = function(reg, func) {
  
      var rtn = [], 
          that = this.toString();
      if (!reg.test(that)) {
          console.log(reg, that, reg.test(that));
          return [that];
      }
  
      ...
  }
  </code></pre>
  
  <p>The console.log should be called ONLY when the String doesn't match <code>reg</code>, right? But sometimes it logs <code>(reg, that, true)</code>. That troublesome String and <code>reg</code> were:</p>
  
  <pre><code>"See &lt;url&gt;http://www.w3.org/TR/html5-diff/&lt;/url&gt; for changed elements and attributes, as well as obsolete elements and"
  /&lt;url&gt;.*?&lt;\/url&gt;/g
  </code></pre>
  
  <p>console logs true. I can't figure out why. Any help would be highly appreciated.</p>