function Person(){ this.name="unseted"; this.sex="boy"; this.getName=function(){ alert(this.name); } this.classroom="Person classroom" }; Person.prototype.getClassRoom=function(){}; /*为类添加属性或者方法有2种方式: * 1.在构造方法中添加 * 2.在原型链中添加,原型是一个对象,对象通俗说又是一个数组,只是function才有原型 */
//注意:添加原型以外的方法,此方法不被Person的实例继承 Person.getSex=function(){ alert("Person sex"); }