Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack {
- constructor(list) {
- this.list = list
- }
- stack() {
- return this.list
- }
- pop(...elms) {
- return new Stack(this.list.concat(elms))
- }
- peek() {
- return this.list[this.list.length - 1]
- }
- pull() {
- return new Stack(this.list.slice(0, this.list.length - 1))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement