title: Creating objects through functions - memory usage
body: <p>If I create custom objects through functions like this:</p>
  
  <pre><code>function createCustomObject ( state ) {
      let obj = { state };
      obj.doSomething = function ( ) {
          // do something
      };
      return obj;
  }
  
  let myNewObject = createCustomObject( { foo: 'bar' } );
  myNewObject.doSomething();
  </code></pre>
  
  <p>How does that work out memory-wise? Does JavaScript keep a separate copy of the <code>doSomething</code> method for each of the objects I create? If I need to create thousands of objects will using prototypes/composition be more efficient?</p>