JSFiddle - React, Tailwind, and code Playground

by LyndseyB

Babel + JSX

class Square {
  constructor(height, width) {
    this.height = height;
    this.width = width;
  }
  
  getWidth() {
  	return this.width;
  }
}

var square = new Square(50, 50);
console.log(`square width: ${square.getWidth()}`);


var Rectangle = function(width) {
	this.width = width || 100;
}

Rectangle.prototype.getWidth = function() {
	return this.width;
}

var rectangle = new Rectangle();
console.log(`reactangle width: ${rectangle.getWidth()}`);