JSFiddle - React, Tailwind, and code Playground

by Pratik Bhonsle

HTML

<button onclick="store.addElement('hello',function(){alert('within!');});console.log(store);">test</button>

JavaScript

var store = {
    elements: [],
    addElement: function(element, callback) {
        this.elements.push(element);
        if (callback !== undefined) {
            callback();
            alert('');
        }
    }
};