サーバーからの関数のコールバックとして、モジュールに属するメソッドを使用しています。
このメソッドから、モジュール ( MyArray
) にカプセル化された配列にアクセスする必要があります。
this
元の関数(someFunction
私の例では)を参照しているため、使用できません。that: this
しかし、この場合に機能を使用できない理由がわかりません( that is undefined
)。
MyModule.js
module.exports = {
MyArray: [],
that: this,
test: functiion() {
//How to access MyArray ?
}
};
サーバー.js
var MyModule = require('MyModule');
someFunction(MyModule.test);