<script>
function Student(name,age){
this.name=name, \\this 代表实例化对象
this.age=age, this.eat=function(){ console.log(this.name+" eating...") 每次创建实例化对象 都会新创建一个方法 } } var s1=new Student('xm','20') console.log(s1); s1.eat; \\ prototype 原型 Student.prototype.sleep=function(tmp){ console.log(this.name) console.log('sleeping....') console.log(tmp) }\\原型下的属性和方法都可以被所有的实例化对象所共享 属性写在方法里 方法写在原型下面