JSFiddle - React, Tailwind, and code Playground

by Vladymyr Shevchuk

Babel + JSX

'use strict';

  class Hamster {
    stomach = [];
    
    eat(food) {
      this.stomach.push(food);
      // this.stomach = food;
    }
  };

  let speedy = new Hamster();

  let lazy = new Hamster();

  // Шустрый хомяк нашёл еду
  speedy.eat('apple');
  console.log(speedy.stomach); // apple

  // Живот ленивого хомяка пуст
  console.log(lazy.stomach); // <ничего>