Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Constructor function for Node
- const Node = function (data) {
- this.data = data;
- this.next=null;
- }
- //Constructor function for Stack
- const Stack = function (){
- this.top=null;
- this.size= 0;
- this.min=null;
- }
- //Just add to prototype and all the objects inherit that behavior
- Stack.prototype.push = function (data){
- //..
- }
- Stack.prototype.pop = function (){
- //..
- }
- Stack.prototype.peek = function (){
- //..
- }
- Stack.prototype.isEmpty = function () {return this.top===null;}
- Stack.prototype.minimum = function () {return this.min}
- let a = new Stack()
- a.push(1)
- a.push(-1)
- a.push(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement