JS 原型 ,原型方法,原型属性,构造函数constructor
产生js对象之前,需要创造一个构造函数
function Person(name,age){
this.name=name,
this.age=age
}
Person.prototype.kill=function(){
return "kill"
};
Person.prototype.localtion="地球";
var kxl=new Person("kxl",24);
//////////////覆盖原型
// kxl.kill=function(){
// return "balabal";
// };
// kxl.localtion="火星";
alert(kxl.age);
alert(kxl.name);
alert(kxl.localtion);
alert(kxl.kill());

浙公网安备 33010602011771号