title: Local function declaration versus pointer to function
body: <pre><code>class Testone{
      constructor(value){
          Object.defineProperty(this, 'doSomething', {
              enumerable: false,
              configurable: false,
              writable: false,
              value: () =&gt; {
                  //do whatever
              }
          });
      }
  } 
  
  const doWhatever = () =&gt; {
      //do whatever
  } 
  
  class Testtwo{
      constructor(value){
          Object.defineProperty(this, 'doSomething', {
              enumerable: false,
              configurable: false,
              writable: false,
              value: doWhatever
          });
      }
  }
  </code></pre>
  <p>My thought is that <code>Testtwo</code> should be more efficient, since <code>doWhatever</code> would only exist in memory once then get pointed to by every instance of <code>Testtwo</code>. <code>Testone</code> would instantiate a new anonymous function for each new instance.</p>
  <ol>
  <li><p>Does <code>Testone</code> actually create a new anonymous function each time? Is <code>Testtwo</code> therefor more efficient or is it also creating separate instances of <code>doWhatever</code>?</p>
  </li>
  <li><p>Am I missing some major caveat to one over the other (other than variable scope)?</p>
  </li>
  </ol>
  <p>My benchmarking consistently shows ~2% difference in instantiation time, with <code>Testtwo</code> indeed being faster... but that's not exactly confirmation.</p>