I have a JSON file here: https://next.json-generator.com/api/json/get/E1qcwkNxr
and I want to use it to create a table. Using jQuery I get the response Array and map some values to build my table body cells:
var data = $.getJSON('https://next.json-generator.com/api/json/get/E1qcwkNxr', function (response) {
// map JSON to local arrays and define local vars
var rows = response.map(function (r) {
return [
r.age,
r.index,
r.registered,
r.balance,
r.eyeColor
];
});
});
I want to do the same thing with the keys because I want to build the thead cells with that data. There's a way to do it? Object.keys(response[0]); log me all the keys in the object, How can I map only the key I want to use?
Object.keys? Is it to reduce duplication of the key names (in map, and then thead building)? Or, another reason?