window.onload = function(){
function A() {
this.str1 = "It's A";
}
function B() {
this.str2 = "It's B";
}
A.prototype.getString1= function () {
alert(this.str1);
}
//B继承A
B.prototype = new A();
B.prototype.getString2 = function() {
alert(this.str2);
}
var b = new B();
b.getString1();
b.getString2();
}
主要是用prototype实现继承,看着还真是不太习惯。