function Dog(option) {
//属性
this.name = option.name;
this.age = option.age;
this.dogFriends = option.dogFriends;
//方法
this.eat = function(something) {
console.log(this.name + '在吃' + something);
};
this.run = function(somewhere) {
console.log(this.name + '跑' + somewhere);
};
}
//小狗
var smallDog = new Dog({
name: '小小',
age: 1
});
smallDog.age = 10;
console.log(smallDog.name, smallDog.age);
smallDog.eat('奶');
smallDog.run('公园');
//大狗
var bigDog = new Dog({
name: '大大',
age: 10,
dogFriends: ['白白', '胖胖']
});
console.log(bigDog.name);
bigDog.eat('apple');
bigDog.run('广场');
console