L
L
Lion452020-09-16 17:34:35
Node.js
Lion45, 2020-09-16 17:34:35

What does displayInfo do in this code?

What does "this.displayInfo = function()" do in this code?
And why doesn't it print "Name: ${this.name} Age: ${this.age}"

function User(name, age) {
    this.name = name;
    this.age = age;
    this.displayInfo = function() {
        console.log(`Имя: ${this.name} Возраст: ${this.age}`);
    }
}
User.prototype.sayHi = function() {
    console.log(`Привет, меня зовут ${this.name}`);
};
module.exports = User;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question