const stack = [1, 2, 3, 4, 5] const element = stack[stack.length - 1] // pop stack stack.length -= 1 const currentParent = stack[stack.length - 1] console.log(element, currentParent)