JSFiddle - React, Tailwind, and code Playground

by Pankaj Kargirwar

JavaScript

class ParentClass {
  constructor() {
    this.parentProperty = "Parent property";
  }

  parentMethod() {
    console.log("Parent method");

    const smaller = new SmallerClass();
    smaller.smallerMethod1.apply(this);

  }
}

class SmallerClass {
  smallerMethod1() {
    console.log(this.parentProperty);
    //smallerMethod2();
  }

  smallerMethod2() {

    console.log(this.parentProperty);
  }
}

const p = new ParentClass();
p.parentMethod();