title: Do methods take up space in the class instance on javascript?
body: <p><a href="https://stackoverflow.com/q/11166956/1233788"> Similar questions for other languages</a>.  </p>
  
  <p>Consider a simple class:</p>
  
  <pre><code>class Foo {
    a;
  
    constructor(value) {
      this.a = value;
    }
  
    bar() {
      console.log(this.a);
    }
  }
  </code></pre>
  
  <p>For each instance of this class, in javascript, will be consumed memory for a reference for <code>bar</code> method?</p>
  
  <p>If I add other methods in <code>Foo</code> class, the instance of it will be heavier on memory?</p>
  
  <p>If I need to create a lot of <code>Foo</code> objects, should I write:</p>
  
  <pre><code>function Foo(value) {
    this.a = value;
  }
  
  function bar(fooInstance) {
    console.log(fooInstance.a);
  }
  </code></pre>
  
  <p>The questions above only illustrate the same question:<br>
  <strong>Do methods take up space in the class instance?</strong></p>