Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. class Stack {
  2. constructor() {
  3. this.head = null;
  4. this.tail = null;
  5. this.count = 0;
  6. }
  7. get length() {
  8. return this.count;
  9. }
  10. push(data) {
  11. //..
  12. }
  13.  
  14. pop() {
  15. //...
  16. }
  17.  
  18. peek() {
  19. //...
  20. }
  21.  
  22. get length() {
  23. //..
  24. }
  25.  
  26. }
  27.  
  28. var stack = new Stack();
  29. stack.push(1);
  30. stack.push(5);
  31. stack.push(3);
  32. console.log(stack.peek());
  33. stack.push(2);
  34.  
  35. stack.pop();
  36. stack.push(7);
  37. stack.printOut(console.log);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement