現在、他のアプリをラップする node.js 内に仮想マシンを実装することを考えています。そのために、いくつかの基本事項をオーバーライドしますが、よくわからない点が 1 つあります。
var A = (function() {
var b = 1;
var A = function() {};
A.prototype.test = function() { // Can't touch this
return b;
};
A.prototype.foo = function(callback) {
callback();
};
return A;
})();
// Objective: Get b without touching `test` in any way
これは何らかの方法で可能ですか?プロトタイプを注入するか、call()、apply()、bind() などを使用して? 他の種類の反省はありますか?