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 ProfessionalHard
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]);
Explanation
The output of the code is 'string' '1'. The Object.fromEntries method converts a Map object to an object, where the keys are strings. Therefore, the typeof Object.keys(obj)