Getting list of fields from identified feature

Discussion created by msbsmith on Apr 9, 2010
Latest reply on Jun 8, 2011 by pkalvala-esristaff
Please help, I've been trying to return a list of field names from a feature when identified, I think it has something to do with fieldAliases but I can't find an example of it being used in code.  I can run through the features one by one and retrieve attributes by hard-coding a field name like so: val = idResult.feature.attributes['UNIQUE_ID'], but I want to write some generic code so I don't have to hard code the field names.
Below is the identify function which is looping through the identified features, can someone please post the few lines necessary to get the field names?  Thanks again, Mark.

function addToMap(idResults, evt) {
for (var i=0, il=idResults.length; i<il; i++) {
    var idResult = idResults[i];

    //Get attribute for a given field name
    val = idResult.feature.attributes['UNIQUE_ID']

    //Instead of above line, need to get list of field names for this feature so I can loop through them