开发者

Access parent object from function in JavaScript

Short question. I have the following situation:

function callbackTest(data, callback) {
     callback.call(data);
}
开发者_如何学运维
var map = new Map("Worldmap");
var data = "My data";
callbackTest(data, map.processData);

So, my question is, wheather or not it is possible to access the map object from inside the callbackTest function?


You can't access map unless you pass it in, or processData has a reference back to map. Basically there's no inherent .parentObject property present when dealing with a generic object here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜