Is there quick way to filter an array of objects to return only a few properties in each object?
For example we have the data below:
var objArr = [{
"Title": "July 13 - July 19 2014",
"displayAd_imp": "3,500",
"videoAd_imp": "1.5",
"tv_imp": "0.52",
"Date": "2014-07-17T00:00:00.000Z",
"WeekNo": 29
}, {
"Title": "July 20 - July 26 2014",
"displayAd_imp": "1,600",
"videoAd_imp": "2.55",
"tv_imp": "0.052",
"Date": "2014-07-24T00:00:00.000Z",
"WeekNo": 30
}, {
"Title": "July 27 - Aug 2 2014",
"displayAd_imp": "1,500",
"videoAd_imp": "2.1",
"tv_imp": "0.122",
"Date": "2014-07-31T00:00:00.000Z",
"WeekNo": 31
}]
I'm trying to filter the array above to get another array with only videoAd_imp, videoAd_imp, tv_imp. so it would look like this:
[{
"displayAd_imp": "3,500",
"videoAd_imp": "1.5",
"tv_imp": "0.52",
}, {
"displayAd_imp": "1,600",
"videoAd_imp": "2.55",
"tv_imp": "0.052",
}, {
"displayAd_imp": "1,500",
"videoAd_imp": "2.1",
"tv_imp": "0.122",
}]
Thanks in advance!
deleteto remove the stuff you don't want. If you want new objects, use.map()and return new objects with only the stuff you do want. There's no built-in solution.JSON.parse().