Javascript基于类的继承

function parent()
{
    var id=1;
    var username="roboth";
    this.getID=function(){return id;}
    this.getUserName=function(){return username;}
}

function child()
{}

var child1=new child();
createInheritance(new parent(),child1);

function createInheritance(parent,child)
{
   var  pro;
   for (pro in parnet)
   {
       if(!child[pro])
       {
             child[pro]=parent[pro];
        }
  }
}



posted @ 2007-07-30 12:02  roboth  阅读(190)  评论(0)    收藏  举报