<script>/*入栈 push出栈 poppeek 获取栈顶 peekisEmpty 判断栈是否为空size 可以看栈中有多少个值*/function Stack(){this.items = [];}Stack.prototype.push = function(val){this.items.push(val)}Stack.prototype.pop = function(){var res = this.items.pop()return res ;}Stack.prototype.peek= function(val){return this.items[this.items.length-1]}var s = new Stack();s.push(2);s.push(3);console.log(s.items);[2,3]console.log(s.pop())//3 出栈</script>
