I want to log out all values in the object. every value logs out fine except the value of "description" property.
Here is my code
const cars = {
make : 'Mazda',
year : 2015,
model : 'CX-5',
style : "SUV",
drive : 'AWD',
description : function(){
return `${this.make} ${this.model} is a capable ${this.drive} ${this.style}`
}
}
const values = Object.values(cars)
for (const value of values){
console.log(value)
}
it logsout like this
return ${this.make} ${this.model} is a capable ${this.drive} ${this.style}
;
instead of this (this is what I want)
Mazda CX-5 is a capable AWD SUV
what can i do to fix this? I need some help.
question from:
https://stackoverflow.com/questions/65651232/console-log-out-a-method-with-template-literal-in-an-object 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…