Jquery - Create new array from an existing array attributes
I am trying to create a new array out of limited values from an existing
array. In the example below LargeArray contains many attributes -year,
books, gdp and control. Lets say i want to create a new array that would
only include year and gdp.
var LargeArray = [{year:1234, books:1200, gdp:1200, control:1200},
{year:1235, books:1201, gdp:1200, control:1200}, {year:1236, books:1202,
gdp:1200, control:1200}, {year:1237, books:1203, gdp:1200, control:1200},
{year:1238, books:1204, gdp:1200, control:1200}];
The new array i am trying t get at, would look like this,
var NewArray = [{year:1234, gdp:1200}, {year:1235, gdp:1200}, {year:1236,
gdp:1200}, {year:1237, gdp:1200}, {year:1238, gdp:1200}];
Thank you in advance!
No comments:
Post a Comment