Arrays are essential in programming
const myArray = [['key1', 'value1'], ['key2', 'value2']];
Creating a Map from an array is a common task.
However, sometimes things don't go as planned:
const myMap = new Map(myArray);
This can lead to errors like:
No overload matches this call.
Overload 1 of 3, '(iterable: Iterable<readonly [unknown, unknown]>): Map<unknown, unknown>', gave the following error.
Argument of type 'string[][]' is not assignable to parameter of type 'Iterable<readonly [unknown, unknown]>'.
...
But fear not! There's a solution:
const myMap = new Map([['key1', 'value1'], ['key2', 'value2']]);