サーバーからの関数のコールバックとして、モジュールに属するメソッドを使用しています。
このメソッドから、モジュール ( 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);