JSFiddle - React, Tailwind, and code Playground

by csnsgiri

JavaScript

// program to implement stack data structure
class Stack {
    constructor(a,b) {
        this.items = a;
        this.cnt =b;
    }       
}

let stack = [];
stack.push(new Stack('a',1));
stack.push(new Stack('b',1));
console.log(stack);
var x = stack.pop();
x.items = 'bs';
x.cnt=2;

console.log(x);
  stack.push(x);
console.log(stack);