<script>function Stack(){this.items =[];}/*入栈 push出栈 poppeek 获取栈顶isEmpty 判断栈是否为空size 可以看栈中是否有多少个只*/Stack.prototype.push = function(val){this.items.push(val);}Stack.prototype.pop = function(){var res = this.items.pop();return res;}Stack.prototype.peek = function(){return this.items[this.items.length-1]}var s =new Stack();s.push(2);s.push(3);console.log(s.items);//console.log(s.pop())console.log(s.peek())</script>
<script>/*Membersnameagesex在Members原型上定义sayNamae方法 console.log(this.name)实例化自己和同桌08里面写*/function Student(name,age,sex){this.name = name;this.age = age;this.sex = sex;}Student.prototype.sayName = function(){console.log(this.name)}Student.prototype.saySkill = function(){console.log(this.age)}Student.prototype.saysex = function(){console.log(this.sex)}var p = new Student("韩磊",21,"男")console.log(p)p.sayName();p.saySkill();p.saysex();var g = new Student("高云锋",20,"男")console.log(g);g.sayName();g.saySkill();g.saysex();</script>
