在 OPP JS 中,您可以从构造函数访问在原型函数内声明的方法吗?

In OPP JS can you access a method declared inside a prototype function from the constructor?

我正在阅读有关 OPP js 的内容,并且在查看示例时想知道是否在:

function Person(name){
    this.name = name;

}

Person.prototype.sayName = function(){

        var tempName = this.name;

        var saySomething = function(){

            console.log(tempName);

    }
    //return saySomething();
}

var person1 = new Person('chris');

有没有办法从构造函数中触发 saySomething 方法。 例如

person1.sayName().saySomething() //which doesnt work obviously

sayName 有效时返回对象:

function Person(name) {
    this.name = name;
}

Person.prototype.sayName = function() {

    var tempName = this.name;

    return {
        saySomething: function() {
            console.log(tempName);
        }
    };
};

var person1 = new Person('chris');
person1.sayName().saySomething(); // logs 'chris'