原型的作用:
1.解决数据共享,节省内存空间
2.实现继承,节省内存空间
实例对象原型: __ proto __,是浏览器使用的
构造函数原型:prototype,是程序员使用的
unction Person(name,age) {
this.name=name;
this.age=age;
}
Person.prototype.eat=function(){
}
var per=new Person("张三",20)
简单的原型写法
Person.prototype={
//手动修改构造器的指向
constructor:Person,
height:"168",
weight:"48kg",
stuly:function(){
}
}