es5
let Animal = function(type){
this.type = type
}
Animal.prototype.eat=function(){
console.log('like eat food')
}
var dog = new Animal("dog");
var mok = new Animal("mok");
console.log(dog);
console.log(mok)
mok.constructor.prototype.eat = function(){
console.log("haihai1")
}
dog.eat()
mok.eat()
es6
class Animal{
constructor(type){
this.type = type
}
eat(){
console.log('eat')
}
}
var dog = new Animal("dog");
var mok = new Animal("mok");
dog.eat()
mok.eat()
```javascript
class Animal{
constructor(type){
this.type = type
}
eat(){
console.log('eat')
}
}
var dog = new Animal("dog");
var mok = new Animal("mok");
dog.eat()
mok.eat()