title: Javascript: how to save object with private fields to file?
body: <p>I've tries to save an object like a string and for this I use <code>JSON.stringify()</code> but it picks up only public fields.  </p>
  
  <p>How to grab privates?</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;script&gt;
          function Class1() {
              var prop1 = 1;
              this.prop2 = 2;
          };
  
          var inst1 = new Class1();
  
          var str = JSON.stringify(inst1);
  
          console.log(str);
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>the output is: {"prop2":2}   </p>
  
  <p>and I want {"prop1":1, "prop2":2} </p>