# JavaScript之面向对象中的多态

> 多态:同一个父类继承出来的子类各有各的形态

- 原文：https://feinterview.poetries.top/blog/JavaScript%E4%B9%8B%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E4%B8%AD%E7%9A%84%E5%A4%9A%E6%80%81
- 来源：前端进阶之旅（feinterview.poetries.top）
- 更新：2016-07-27

---

- 多态:同一个父类继承出来的子类各有各的形态
<!--more-->

```javascript
function Cat(){
	this.eat = '肉';
}

function Tiger(){
	this.color = '黑黄相间';
}

function Cheetah(){
	this.color = '报文';
}

function Lion(){
	this.color = '土黄色';
}

Tiger.prototype =  Cheetah.prototype = Lion.prototype = new Cat();//共享一个祖先 Cat

var T = new Tiger();
var C = new Cheetah();
var L = new Lion();

console.log(T.color);
console.log(C.color);
console.log(L.color);

console.log(T.eat);
console.log(C.eat);
console.log(L.eat);

```
