JSFiddle - React, Tailwind, and code Playground

by colintoh

JavaScript

var Gallery = function(name) {
    this.name = name;
}

Gallery.prototype.methods = {
    activeCnt: 0,
    inc: function() {
        this.activeCnt++;
    },
    dec: function() {
        this.activeCnt--;
    },
    talk: function() {
        alert(this.activeCnt);
    }
}


var artGallery = new Gallery('art');
var carGallery = new Gallery('car');
artGallery.methods.inc();
artGallery.methods.talk();
carGallery.methods.talk();