function Stack(){}Stack.prototype.push = function (v){ this.head = { v:v, next:this.head };};Stack.prototype.pop = function () { if(this.head.next !== undefined){ var top = this.head.v; this.head = this.head.next; console.log(top); return top; }else{ console.log(this.head.v); return this.head.v; }};复制代码