title: ECMAScript/Node: is it possible to save an object instance or context to the filesystem?
body: <p>Is it possible to save an object (instance of a class) to the filesystem including its internal values?</p>
  
  <p><em>Please do not flag as off-topic.</em> I understand that even if this is somehow achievable, it is not common practice. It doesn't matter either if it is hacky. I am just curious if it can be achieved because it is sunday 8 oclock and I had a long day.</p>
  
  <pre><code>function Node() {
      let x = Math.random()
      this.data = function() {
          return x
      }
  }
  
  let node1 = new Node()
  // save it to the disk somehow as node1
  saveNode('node1', node1)
  // load it back from the disk into memory somehow, perhaps using eval??
  let savedNode = loadNode('node1')
  
  console.log(
     savedNode.data(), 
     node1.data()
  ) /* these should be the same */
  </code></pre>
  
  <p>You can stringify an object including its functions by using a 'modifier' function as second argument in JSON.stringify but that won't do the trick here.</p>