对象不会从原型函数返回

object will not return from prototype function

本文关键字:函数 返回 原型 对象      更新时间:2023-09-26

我像这样实例化一个对象:(我的意思是当我说数组时说对象)

text_object = new SText( form_elements );

出于调试的目的,我这样称呼它:

console.log('text_array in caller' + ( text_object.getArray().toSource() ) );

实际函数如下所示:

SText.prototype.getArray = function( ) {
    console.log('text_array in getArray' + this.text_array.toSource() );
    return this.text_array;
};

控制台.log在实际函数中显示数组,但永远不会返回:这是日志:

[15:16:44.160] text_array in getArray({url:"http://a.com", title:"a", tag:"a", domain:"a.com", path:"http://www.google.com/s2/favicons?domain=a.com"})
[15:16:44.162] text_array in Caller({})

你试过吗

console.log('text_array in caller' + text_object.getArray().toSource());