// how to convert object to array in javascript
// using Object.entries()
const credits = { producer: 'John', director: 'Jane', assistant: 'Peter' };
const arr = Object.entries(credits);
console.log(arr);
/** Output:
[ [ 'producer', 'John' ],
[ 'director', 'Jane' ],
[ 'assistant', 'Peter' ]
]
**/
// if you want to perfrom reverse means array to object.
console.log(Object.fromEntries(arr)); // { producer: 'John', director: 'Jane', assistant: 'Peter' }
// convert object values to array
// using Object.values()
console.log(Object.values(credits)); // [ 'John', 'Jane', 'Peter' ]
// convert object keys to array
// using Object.keys()
console.log(Object.keys(credits)); // [ 'producer', 'director', 'assistant' ]