## **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);
```