title: Infinite loop when converting knockout object to plain JavaScript object
body: <p>Folliwing instructions given in the <a href="http://knockoutjs.com/documentation/json-data.html" rel="nofollow noreferrer">documentation</a>, I have the following view model:</p>
  
  <pre><code>var newContactViewModel = function () {
      var self = this;
  
      self.Name = ko.observable();
      self.Address = ko.observable();
      self.City = ko.observable();
      self.State = ko.observable();
      self.PostalCode = ko.observable();
  
      self.Save = function () {
          $.ajax({
              type: "POST",
              url: "/contact",
              data: ko.toJS(self), //infinite loop here
              success: state.OnSaved
          });
      };
  };
  </code></pre>
  
  <p>When the <code>self.Save</code> method is called, an infinite loop occurs. Chrome actually reports the error as:</p>
  
  <blockquote>
    <p>Uncaught RangeError: Maximum call stack size exceeded</p>
  </blockquote>
  
  <p>If I use <code>ko.mapping.toJS(self)</code> instead of <code>ko.toJS(self)</code>, then I get a slightly more revealing error, but no real error "message":</p>
  
  <p><img src="https://i.stack.imgur.com/eytUh.png" alt="infinite loop error"></p>
  
  <p>If I swap <code>ko.toJS(self)</code> out with something like <code>{ Name: self.Name(), Address: self.Address() /* etc */ }</code>, then everything works fine. It seems like it's trying to convert the <code>Save</code> method and re-calling the method as a result.</p>
  
  <p>There's either a bug in KnockoutJS or there's a problem when how I'm using it. I'd prefer the latter. Thoughts?  </p>