Hi,
function createPerson(name) {
const obj = {};
obj.name = name;
obj.introduceSelf = function () {
console.log(Hi! I’m ${this.name}.);
};
return obj;
}
undefined
const salva = createPerson(“Salva”);
salva.name;
salva.introduceSelf();
const frankie = createPerson(“Frankie”);
frankie.name;
frankie.introduceSelf();
VM1328:5 Hi! I’m Salva.
VM1328:5 Hi! I’m Frankie.
You sent
But can you tell this below statements in class declaration in javascript by Constructor
class Professor {
name: “Kaushik”,
greet() {
console.log(Greetings from ${this.name}
);
}
introduceSelf: function () {
console.log(Hi! I'm ${this.name}.
);
}
}
Thanks
Kaushik