How nodejs module.exports references methods in a class prototype

a.js
this is node to export a class
let Person = function () {

this.name = ";

}
Person.prototype = {

constructor:Person,
say:function () {
    console.log("my name is "+this.name);
}

};
module.exports.Person = Person;
b.js
reference a.js file
let Person = require (". / a.js");
let person = new Person ("Zhang San");
console.log (person.say ());

)

Why did you finally output my name is Zhang San and undefined

Mar.31,2021

person.say () is a method that does not return anything
you console.log directly (person.say ()) is undefined of course

Menu