JavaScript Coding Question – 13

Output:

[
  [ 'firstName', 'abc' ],
  [ 'lastName', 'xyz' ],
  [ 'age', 50 ]
]
  • Above code will convert the properties of the Person object into an array of key-value pairs using Object.entries().
  • Object.entries(Person) : takes each property of the Person object and convert it into an array, where each element is a [key, value] pair.

Leave a comment