I currently have an array of objects where each object has several properties. Example:
[
{ text: 'test1',
id: 1
},
{ text: 'test2',
id: 2
}
]
What would be the best way to convert this to an array of strings that contains the value from text
? I had thought I might be able to do this using underscore.js:
headerText = _.pick(headerRow, 'text');
But I think that since the objects are in an array this will not work. My next idea is to just loop through each element in the array and push the text
value to a new array, but i'm curious if anyone knows of a more elegant way to do this? Suggestions?