I want to initialize this.detailImgUrls with concatImgUrls () when initializing the object. Which of the following methods should I use?
function concatImgUrls() {
return "haha";
}
export default class Car{
constructor(data){
this.address = data.address;
this.displacement = data.displacement + "L";
this.detailImgUrls = concatImgUrls();
}
}
export default class Car{
constructor(data){
this.address = data.address;
this.displacement = data.displacement + "L";
this.detailImgUrls = this.concatImgUrls();
}
concatImgUrls() {
return "haha";
}
}
I tried both, but in the second case, the object method is supposed to be used by the instantiated object, not in the class.