## **js對象**
#### **new Object**
Object 是一個構造函數.
new的方式來調用構造函數
new Object()調用構造函數 ,會在內存中創建一個對象
```
var hero = new Object(); //創建一個空對象
console.log(hero.name); //打印undefind
hero.name='黃忠';
hero.weapon = '弓箭'
hero.equipment=['頭盔','靴子','盔甲'];
hero.blood=100;
//方法
hero.attack = fiunction () {
console.log(this.name + ':射箭')
}
hero.run= fiunction () {
console.log(this.name + ':瞬移')
}
```
#### **對象字面量**
```
var hero={
name:'黃忠',
weapon : '弓箭',
equipment:['頭盔','靴子','盔甲'],
blood:100,
//方法
attack: fiunction () {
console.log(this.name + ':射箭')
}
run:fiunction () {
console.log(this.name + ':瞬移')
}
}
console.log(hero.name);
console.log(hero.equipment);
```