What is the output of the following code? const map = new Map([[1, ‘a’], [2, ‘b’], [3, ‘c’]]); const obj = Object.fromEntries(map); console.log(typeof Object.keys(obj)[0], Object.keys(obj)[0]);

JavaScript Professional Hard

JavaScript Professional — Hard

What is the output of the following code? const map = new Map([[1, ‘a’], [2, ‘b’], [3, ‘c’]]); const obj = Object.fromEntries(map); console.log(typeof Object.keys(obj)[0], Object.keys(obj)[0]);

Key points

  • Object.fromEntries converts Map keys to strings
  • typeof Object.keys(obj)

Ready to go further?

Related questions