How to convert an arrangement of type objects [{name: value}...] into a value arrangement?



  • How can I turn this

    [{"name":"All"},{"name":"NodeJS"},{"name":"ReactJS"},{"name":"PHP"},{"name":"Wordpress"},{"name":"Joomla"}]
    

    In this

    ["All", "NodeJS", "ReactJS", "PHP", "Wordpress", "Joomla"]
    

    Maybe it's a very simple thing but no idea how to do it.



  • You just need to use the function https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/Array/map :

    let data = [{"name":"All"},{"name":"NodeJS"},{"name":"ReactJS"},{"name":"PHP"},{"name":"Wordpress"},{"name":"Joomla"}];
    

    let values = data.map(function(entry) {
    return entry.name;
    });

    console.log(values);


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2