日期:2014-05-16 浏览次数:20517 次
function extend(target,parent,params){
parent.apply(target,params);
var p = null,o;
for(p in parent.prototype){
o = target.constructor.prototype;
if(!o[p]){
o[p] = parent.prototype[p];
}
o[p]["super"] = parent.prototype;
}
};function Person(name){
this.name = name;
};
Person.prototype.getName = function(){
alert(this.name);
}
function Student(name){
extend(this,Person,[name]);
};var stu = new Student("lynn");
stu.getName();