我有一个原型对象,其中包含一个对象数组。其中一个数组对象被传递给一个函数,我需要访问它来自的原始对象...获取原始原型对象内给定一个变量存储在原始原型
有没有任何方法可以在不知道原始对象的名称的情况下做到这一点?
例子:
function ObjectA {
this.attribute[0] = new ObjectB;
}
ObjectB.prototype.func = function (s) {
//I have the attribute[0] (an object) here, i need to access A
from it
}
var objectA = new ObjectA(data);
objectA.attribute[0].func(3);
也许你需要编辑你的问题来改进代码部分? – Kalamarico
你的问题不清楚 – marvel308
你的问题的代码没有显示任何正在建立的原型。 –