前言:我认为prototype是用来扩展对象的属性和方法的,至少目前用到的是这样的。

1、扩展对象属性

var  user=function (){

   this.name="PJL";

   this.age="21";

  this.gender="male";

}

user.prototype.id=20;

user.prototype.district='CN';

2、扩展对象的方法

user.prototype.sayHello=function(){

   alert("hello!Ladies and gentlemen.....");

}

user.prototype.play=function(){

   alert("Let's play outside when you back!");

}

var myself=new user();

alert("id"+myself.id+",name:"+myself.name);

myself.sayHello();

注:如有理解错误之处希望指正不甚感激!