JSFiddle - React, Tailwind, and code Playground

Babel + JSX

class AbstractShape {

  constructor(type) {
    this.type = type;
  }

  getType() {
    console.log(`I am a ${this.type}`);
  }
}

class Square extends AbstractShape {
  constructor(type) {
    super(type);
    this.sides = 4;
  }
  
  getDescription() {
  	console.log(`I have ${this.sides} sides`);
  }
}

class ShapeFactory {
	static issue(type) {
  	switch(type) {
      case 'Square': return new Square(type); 
        break;
      case 'Circle': /* same pattern with a Circle class */ 
        break;
    }
  }
}

let shape = ShapeFactory.issue('Square');

shape.getType();        /* I am a Square */
shape.getDescription(); /* I have 4 sides */