title: Array of objects to database and back
body: <p>I have array of functions/objects which I want to store to database, like this example:</p>
  
  <pre><code>function classPerson(firstName, lastName, activeStatus) {
      this.firstName = firstName;
      this.lastName = lastName;
      this.activeStatus = activeStatus;
      this.identify = function () {
          return this.firstName + " " + this.lastName;
      }
  } // element
  
  var persons = [];
  var personsFromDatabase = [];
  
  // define persons
  var personOne = new classPerson('Bruce', 'Lee', true);
  var personTwo = new classPerson('Chuck', 'Norris', false);
  var personThree = new classPerson('Steven', ' Seagal', true);
  
  // add persons to array
  persons.push(personOne);
  persons.push(personTwo);
  persons.push(personThree);
  
  // show persons data
  for (var i = 0; i &lt; persons.length; i++) {
      alert(persons[i].identify());    
  }
  
  // store to database
  var toDatabase = JSON.stringify(persons);        
  alert(toDatabase);
  
  // retrieve from database
  var personsFromDatabase = JSON.parse(toDatabase);
  
  // show persons data parsed from database
  for (var i = 0; i &lt; personsFromDatabase.length; i++) {
      alert(personsFromDatabase[i].identify());    
  }
  </code></pre>
  
  <p>I transform persons array to string with JSON.stringify command and successfully store it to database.
  When I load same string from database and transform back with JSON.parse to JS function/object I get list of simple objects (and error </p>
  
  <blockquote>
    <p>TypeError: personsFromDatabase[i].identify is not a function</p>
  </blockquote>
  
  <p>) instead of classPerson function/object and in console I can see that difference, like on picture below:
  <a href="https://i.stack.imgur.com/SpVtw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SpVtw.png" alt="Console view"></a></p>
  
  <p>How can I achieve to get array of functions/objects instead of simple JS objects?</p>
  
  <p><a href="https://jsfiddle.net/kendzi/q8an74vc/31/" rel="nofollow noreferrer">Fiddler link with example</a></p>