How to create array from specific key values in JSON with JavaScript

1 Answer

0 votes
const data = {
    "01": {
        "id" : "0101",
        "title" : "title1",
        "age" : "100",
    },
    "02": {
        "id" : "0202",
        "title" : "title2",
        "age" : "97",
    },
    "03": {
        "id" : "0303",
        "title" : "title3",
        "age" : "89",
    },
};

const titles = Object.values(data).map(({title}) => title);

console.log(titles);



  
    
    
/*
run:
    
["title1", "title2", "title3"]
    
*/

  

 



answered Nov 26, 2020 by avibootz

Related questions

...