Digamos que tengo un objeto como este:
const recordCollection = { 2548: { albumTitle: 'Slippery When Wet', artist: 'Bon Jovi', tracks: ['Let It Rock', 'You Give Love a Bad Name'] }, 2468: { albumTitle: '1999', artist: 'Prince', tracks: ['1999', 'Little Red Corvette'] }, 1245: { artist: 'Robert Palmer', tracks: [] }, 5439: { albumTitle: 'ABBA Gold' } };Sé que puedo imprimir una sola propiedad como esta:
console.log (recordCollection[2548]['artist'];Y me pregunto si es posible hacer algo como esto:
console.log (recordCollection[2548]['artist', 'tracks'];¿Cómo imprimiría tanto el artista como las pistas?
Debería ser: recordCollection[2548]['artist']
const recordCollection = { 2548: { albumTitle: 'Slippery When Wet', artist: 'Bon Jovi', tracks: ['Let It Rock', 'You Give Love a Bad Name'] }, 2468: { albumTitle: '1999', artist: 'Prince', tracks: ['1999', 'Little Red Corvette'] }, 1245: { artist: 'Robert Palmer', tracks: [] }, 5439: { albumTitle: 'ABBA Gold' } }; console.log(recordCollection[2548]['artist']);