Advertisement
Guest User

Untitled

a guest
May 26th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. class Stack {
  2. constructor(list) {
  3. this.list = list
  4. }
  5.  
  6. stack() {
  7. return this.list
  8. }
  9.  
  10. pop(...elms) {
  11. return new Stack(this.list.concat(elms))
  12. }
  13.  
  14. peek() {
  15. return this.list[this.list.length - 1]
  16. }
  17.  
  18. pull() {
  19. return new Stack(this.list.slice(0, this.list.length - 1))
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement