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];
}
}
}
{
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];
}
}
}

浙公网安备 33010602011771号