/    Sign up×
Community /Pin to ProfileBookmark

Identify Calling Object

Hey there, can anyone point me towards any information on identifying what object called a function? For example, say you have this object:

[code]var myObject = {
onLoad: function(){
masterObject.callMe();
}
};

var masterObject = {
callMe: function(){
window.alert(‘I was called by the object ——–‘);
}
};[/code]

How could I, for example, get that to display “I was called by the object myObject” if myObject.onLoad() was called?

I don’t really need to know the name of the object… all I need is a reference to the object.

Thanks in advance!

-Matt

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mrhooSep 06.2006 — arguments.callee.caller
Copy linkTweet thisAlerts:
@KravvitzSep 07.2006 — arguments.callee.caller is not included in ECMAScript, so it may not be supported cross-browser.

I don't know of another way to do that.
×

Success!

Help @patenaudemat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...