菜鸟进化史 2014-09-16
1.js对象的继承方式使用prototype原型模式。
2.js的方法可以分为以下三类:
a.类方法
b.对象方法
c.原型方法
function People(name)
{
this.name=name;
//对象方法
this.Introduce=function(){
alert("My name is "+this.name);
}
}
//类方法
People.Run=function(){
alert("I can run");
}
//原型方法
People.prototype.IntroduceChinese=function(){
alert("我的名字是"+this.name);
}
//测试
var p1=new People("Windking");
p1.Introduce();
People.Run();
p1.IntroduceChinese();3.obj1.func.call(obj)方法
是将obj看成obj1,调用func方法