JSFiddle - React, Tailwind, and code Playground

by Reiot

HTML

Hello

JavaScript

$(function() {
    var Barrier = function(name) {
        this.name = name | 'nonamed';
        this.counter = 0;
    };

    $.extend(Barrier.prototype, {
        enter: function() {
            this.counter++;
            console.log(this.name, this.counter);
        },
        leave: function() {
            this.counter--;
            console.log(this.name, this.counter);
        },
        isClear: function() {
            return this.counter == 0;
        }
    });

    var b = Barrier('aa');
    b.enter();

});