javascript 继承的实现

<script>
$(document).ready(function() {
function Fun(a, b) {
this.name = a;
this.addr = b;
}
Fun.prototype.options = {};
$.extend(Fun.prototype.options, {
a : "a",
b : "b",
c : "c"
});
$.extend(Fun.prototype, {
show : function() {
alert("show__________" + this.name + "----" + this.addr);
}
});
Fun.prototype.test = {
"hello" : "kitty"
};
$.extend(Fun.prototype.test, {
"helloKitty" : function() {
},
"onPiece" : function(obj) {
alert(obj.name + "----------" + obj.addr);
},
"donaldDuck" : function() {
alert("helloWorld");
}
});
var fun = new Fun("pikachu", "dracula");
alert(fun.options.a);
fun.show();
fun.test.onPiece(this);

});
</script>

posted @ 2012-07-06 11:28  rhino  阅读(407)  评论(0编辑  收藏  举报