面向对象:我。吃(火锅)
面向过程:吃(我,火锅)
面向过程:
let eat=function(who,food){
console.log(`${who}吃${food}`)
}
eat('我','火锅')
面向对象:
let Person={
name:'我',
eat(food){
console.log(`${this.name}吃${food}`)
}
}
Person.eat('火锅')
function Person(name){
this.name=name;
this.eat=function(food){
console.log(`${this.name}吃${food}`)
}
}
//Person.prototype.eat=function(food){
// console.log(`${this.name}吃${food}`)
//}
let me=new Person('我');
me.eat('火锅')