JSFiddle - React, Tailwind, and code Playground

by Julien Etienne

HTML

<div></div>

JavaScript

var Person = function (element) {
    this.element = element;
    this.name = "";
    this.age = 0;
    this.city = "";

    return {
        setName: function (name) {
            this.name = name;
            return this;
        },

        setAge: function (age) {
            this.age = age;
            return this;
        },

        setCity: function (city) {
            this.city = city;
            return this;
        },

        save: function () {
            console.log("Saving Person [" + "Name : " + this.name + ", " + "Age : " + this.age + ", " + "City : " + this.city + "]...");
            console.log(this.element);
            return this;
        }
    };
};


var div = document.getElementsByTagName('div')[0];
console.log(div);

new Person(div).setName("Colin")
    .setAge(35)
    .setCity("London")
    .save();