how can I display string representation of a variable and not the value it contains.
I know eval can take string and evaluate to a variable but what's the other way?
how can I display string representation of a variable and not the value it contains.
I know eval can take string and evaluate to a variable but what's the other way?
It seems you are asking about property names, not variable names.
If you are getting an array of property names and you have a reference to the related object, you can use square bracket notation to access the named properties of the object:
var obj = {foo: '...', bar: '...', ...};
var propertyNames = ['foo', 'bar', ...];
for (var i=0, iLen=propertyNames.length; i<iLen; i++) {
if (obj[propertyNames[i]] == someValue) {
// do stuff
} else {
// do other stuff
}
}