Object entry() method

Find out all the information about the JavaScript entry() method of the Object object


This method returns an array containing all the properties of the object itself, as[key, value]Correct.


const person = { name: 'Fred', age: 87 }
Object.entries(person) // [['name', 'Fred'], ['age', 87]]

Object.entries()Also applies to arrays:

const people = ['Fred', 'Tony']
Object.entries(people) // [['0', 'Fred'], ['1', 'Tony']]

You can use it to count the number of attributes contained in an object, andlengthThe attributes of the array.

Download mine for freeJavaScript beginner's manual

More js tutorials: