implement inheritance by object masquerading


<script language="javascript" type="text/javascript">
function clsA(){
    
this.color="red";
    
this.sayColor=function(){
        alert(
this.color);
        }
    
this.sayColorAgain=function(){
        alert(
this.color);
    }
    
}
function clsB(){
    
this.color="green";
    
//this.prox=clsA;
    //this.prox();
    //delete this.prox;
    //clsA.call(this);
    clsA.apply(this);
}
var clsb=new clsB();
clsb.sayColor();
clsb.sayColorAgain();
</
posted @ 2009-05-12 16:18  roboth  阅读(122)  评论(0编辑  收藏  举报