## **工厂方法**
```
function createHero(name,weapon,equipment,blood) {
var hero =new Object();
hero.name=name;
hero.weapon =weapon;
hero.equipment=equipment;
hero.blood=blood;
//方法
hero.attack = function () {
console.log(this.name + ':射箭')
}
hero.run= function () {
console.log(this.name + ':瞬移')
}
return hero;
}
var hero1=createHero('黄忠','弓箭',['头盔','靴子'],100);
var hero2=createHero('刘备','剑',['头盔','靴子'],90)
```