Sobes.tech
Junior — Senior

Debugging error when copying Map in JavaScript

livecode

Task condition

In this task, you need to identify the problem in the provided code snippet.

 type Metadata = {}

 type UserMetadata = Map<string, Metadata>;

 const storage: UserMetadata = new Map();

 console.log(storage.get('foo'));

 const storageCopy: UserMetadata = {...storage};

 console.log(storageCopy.get('foo'));

Note that the spread operator is used to copy the map. Determine why the second get call results in an error and how to correctly copy the Map structure.