javascript对象冒充示例
<script type="text/javascript">
function Animal(name,age){
this.name=name;
this.age=age;
this.eat=function(){
alert("动物可以吃东西");
}
}
function Dog(name,age){
//把Animal构造函数赋给this.an
this.an=Animal;
//运行调用@!!!!非常重要
this.an(name,age);
}
var dog=new Dog("小白",2);
alert(dog.name);
dog.eat();
</script>