Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  23] [ 4]  / answers: 1 / hits: 21946  / 14 Years ago, wed, august 25, 2010, 12:00:00

Possible Duplicate:

Determine original name of variable after its passed to a function.






I would like to know if its possible to get the actual name of a variable.



For example:



var foo = 'bar';
function getName(myvar) {
//some code
return foo
};


So for getName(foo) will return foo



Is that possible ?



Thanks.


More From » variables

 Answers
13

I don't think it is possible. When you call a function you pass an object, not a variable. The function doesn't care where the object came from.



You can go the other way though if you call your function as follows:



getName('foo') 


Or pass both the value and the name:



getName(foo, 'foo') 

[#95815] Monday, August 23, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
albert

Total Points: 652
Total Questions: 105
Total Answers: 108

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;