tengo un objeto:
[ { "id": 10, "name": "comedy" }, { "id": 12, "name": "documentary" }, { "id": 11, "name": "scifi" } ] Necesito tomar solo los valores de id y agregarlos en 1 matriz de esta manera:
[ 10, 12, 13 ]
o
{ 10, 12, 13 }
Estoy intentando:
const getIDs = value.map( ( { id } ) => ( { id: id } ) );Pero crea:
[ { "id": 10 }, { "id": 12 }, { "id": 11 } ]Dentro del mapa, simplemente devuelva los valores de identificación en lugar de los objetos.
Aquí está la solución rápida
const values = [ { "id": 10, "name": "comedy" }, { "id": 12, "name": "documentary" }, { "id": 11, "name": "scifi" } ] const getIDs = values.map(({id}) => id); console.log(getIDs)