JSFiddle - React, Tailwind, and code Playground
JavaScript
function Stack() {
const items = []
return items;
}
const stack = Stack();
stack.push(3)
stack.push(2)
stack.push(1)
console.log(stack.pop()); // logs 1
stack.length = 0; // erases the stack
console.log(stack.pop()); // logs undefined (broken!)