原型相关原理

 原型:保存了多个子对象共有成员的属性;

          每一个构造函数都有一个原型属性,引用了该构造函数对应的原型对象;

          由构造函数创建的每个对象中都有一个__proto__属性,只想构造函数的原型对象。

 

function Student(name, age) {             function Student(name, age) {
    this.name = name;                             this.name = name;
    this.age = age;                                   this.age = age;
    this.intro = function(){};                }
}                                                        Student.prototype.intro=function(){}

var lilei = new Student("Li Lei", 18);
var hmm = new Student("Han Meimei", 19);

 

posted @ 2016-08-01 15:51  slting  阅读(124)  评论(0)    收藏  举报