Is there a way in javascript to concatenate named / indexed fields (say, one field of each object) of several objects into a string.
var theArray = [{ field1: "TEXT", field2: "VAL" ... }, { field1: "text", field2: "val" ... } ... ];
For the sake of ideomatics (ideomatic programming), I would like to know if there is a way to connect the values โโof all field1 in an array WITHOUT a for loop.
Sort of
theArray.getFieldValues[0].join(', ');
What options do we have?
- overload Array - wouldnโt do it,
- auxiliary function - I do not want cycles.
There are filter and grep functions in jQuery, but they only filter elements, I would like to know if there is something like
theArray.grepNewObject(function(o){ return o.field1; }).join(', ');
source share