Subj : Re: Can a JS object determine its own variable name? To : netscape.public.mozilla.jseng From : Martin Honnen Date : Wed Jul 20 2005 04:13 pm Mark Turansky wrote: > Can i create a function in the, say, String prototype that can access its > own variable name? > > var username = new String("myvalue"); > > String.prototype.getVariableName = > function(){ > // possible to determine the variable name "username" here? > } No, an object is not necessarily associated with a variable at all and not necessarily stored within one variable only e.g. you could have var s1, s2; s1 = s2 = new String("myvalue"); what would you expect your function to return? -- Martin Honnen http://JavaScript.FAQTs.com/ .