I have an array containing 100.000 objects. Those objects have multiple key/value pairs.
Example of my array:
var data = [
{
"name": "John",
"id": 1,
"completed": "yes",
"prio": 3,
"importance": 2
},
{
"name": "Jim",
"id": 2,
"completed": "yes",
"prio": 4,
"importance": 4
}
]
As shown below I created a new array from the existing one but now with selected key/value pairs from the original array.
var newData = [];
for (var i = 0; i < data.length; i++) {
newData[i] = {"name": data[i].name, "id": data[i].id};
console.log(newData[1]);
}
As you can also see I logged the new array to the console. But what I actually need is to store the array newData
in a separate file in which I can see all the objects of the array like in my example array data
. To be able to see all the objects of newData
is actually not that important but would be nice for working with the array later on. For example I'd like to use R for better understanding of the data.
How can I do that?
NOTE: I'm in the browser!
I'm really struggling with that problem and would be glad if someone could help me …
Thanks!