I\'m not sure if the title is appropriate for what I am trying to achieve
I am mapping JSON results to an array. Because I need to do this over and over again I woul
You will need to pass the item
object and a map of item-keys to entry-keys. This could either be two arrays, an array of tuples or something, or an object. Most simple method I could think of is to change the descriptor object into the entry itself:
function mapPropertyNames(source, dest) {
for (var prop in dest)
dest[prop] = source[dest[prop]];
return dest;
}
// and use it like this:
var map = $.map(data, function(item, i) {
return mapPropertyNames(item, {key:"something1", value:"something2"});
});