面向對象:我。吃(火鍋)
面向過程:吃(我,火鍋)
面向過程:
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('火鍋')