</pre><pre name="code" class="javascript"><script type="text/javascript">
function Animal(name,age){
this.name = name;
this.age = age;
this.action = function(){
console.log('animal action');
}
}
Animal.prototype.sleep = function(){
console.log('animal sleep');
}
Animal.prototype.eat = function(){
console.log('animal eat');
}
function Bird(name){
this.name = name;
}
Bird.prototype = new Animal('animalname',0);
Bird.prototype.constructor = Bird;
var birdObject = new Bird('乌鸦');
</script>
js 继承 实例图示详解
最新推荐文章于 2020-12-25 18:04:16 发布