JSFiddle - React, Tailwind, and code Playground

JavaScript

var ObjectStack = function(obj) {
    this.object = obj;
    this.stack=[];
};
ObjectStack.prototype.push = function(key,value) {
    this.object[key]=value;
    this.stack.push(key);
};
ObjectStack.prototype.pop = function() {
    var key = this.stack.pop();
    var prop = this.object[key];
    delete this.object[key];
    return prop;
};

var my_obj = {};
var my_stack = new ObjectStack(my_obj);
my_stack.push("prop1",12);
my_stack.push("prop2","something");

var last_prop = my_stack.pop(); //something
console.log(last_prop);
last_prop = my_stack.pop(); // 12
console.log(last_prop);