title: JSON.stringify converting Infinity to null
body: <p>I have JavaScript Object say:</p>
  
  <pre><code>var a = {b: Infinity, c: 10};
  </code></pre>
  
  <p>When I do</p>
  
  <pre><code>var b = JSON.stringify(a);
  </code></pre>
  
  <p>it returns the following</p>
  
  <p>b = "{"b":null, "c":10}";</p>
  
  <p>How is the JSON.stringify converts the object to strings?</p>
  
  <p>I tried <a href="https://developer.mozilla.org/en-US/docs/Using_native_JSON">MDN Solution</a>.</p>
  
  <pre><code>function censor(key, value) {
    if (value == Infinity) {
      return "Infinity";
    }
    return value;
  }
  var b = JSON.stringify(a, censor);
  </code></pre>
  
  <p>But in this case I have to return the string "Infinity" not <code>Infinity</code>. If I return Infinity it again converts Infinity to null.</p>
  
  <p>How do I solve this problem.</p>