Skip to content

Instantly share code, notes, and snippets.

@ranamahmud
Created November 2, 2020 14:42
Show Gist options
  • Save ranamahmud/4f8fb1ee9ea7510f657760a3840da539 to your computer and use it in GitHub Desktop.
Save ranamahmud/4f8fb1ee9ea7510f657760a3840da539 to your computer and use it in GitHub Desktop.
var stack = [];
console.log(stack);
// [] // output
// insert a
stack.push("a");
// insert b
stack.push("b");
// insert c
stack.push("c");
// print the stack
console.log(stack)
VM514:1 (3) ["a", "b", "c"]
// poping gives the top element c
stack.pop()
"c"
// popping gives next the top element b
stack.pop()
"b"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment