Binding vs Non-Binding

Edit on GitHub

Setup

Tests

  • Binding

    class Foo {
      constructor() {
        this.a = this.a.bind(this);
      }
    
      a() {
        console.log('foo');
      }
    }
    
    (new Foo()).a();
  • Non-Binding

    class Foo {
      a() {
        console.log('foo');
      }
    }
    
    (new Foo()).a();