Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack {
- constructor() {
- this.head = null;
- this.tail = null;
- this.count = 0;
- }
- get length() {
- return this.count;
- }
- push(data) {
- //..
- }
- pop() {
- //...
- }
- peek() {
- //...
- }
- get length() {
- //..
- }
- }
- var stack = new Stack();
- stack.push(1);
- stack.push(5);
- stack.push(3);
- console.log(stack.peek());
- stack.push(2);
- stack.pop();
- stack.push(7);
- stack.printOut(console.log);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement