JSFiddle - React, Tailwind, and code Playground

by gisheri

HTML

<div class='output'></div>

JavaScript

people = [];

show = function(message){
    $('.output').empty();
    $('.output').text(message);
}

var Person = {
    create: function(name, age) {
        person = Object.create(this);
        person.age = age;
        person.name = name;
        people.push(person);
        return person;
    },
    
    sayhi: function(){
        console.log('hello');
        show('hello '+this.name);
    }
}


var Eric = Person.create('Eric', 24);
Eric.sayhi();