Subj : Re: Object caller references To : netscape.public.mozilla.jseng From : Martin Honnen Date : Tue Aug 09 2005 10:15 pm Neil Stansbury wrote: > function myObj() { > this.parent = myObj.caller; > } > > var obj = new myObj1(); > > // Now obj.parent == this Which this? If you simply call the above code at the global level then I think caller is null as it is the calling function and in that case there is no calling function. > 1) Is this bad JS form - is there a better way? functionObject.caller is not standardized, indeed in ECMAScript edition 3 there is no property defined at all to give you the calling function. So whether using functioObject.caller is bad form depends on where you want to use it, if you have an implementation implementing it and don't care about compatibility then you might use it but if you write script for the web then it is of no use. -- Martin Honnen http://JavaScript.FAQTs.com/ .