How can I pull keys, values and entries off an object?

// Define an object
const animals = { a: 'ape', b: 'bat'}

// Pull off the keys of the object
const keys = Object.keys(animals)
console.log('The keys are ', keys)

// Pull off the values of the object
const values = Object.values(animals)
console.log('The values are ', values)

// Pull off the entries of the object
const entries = Object.entries(animals)
console.log('The entries are ', entries)

Last updated

Was this helpful?