Which fix removes the bug?
const seen: Map<string, number> = new Map(); seen['a'] = 1; console.log(seen.size);
- Store it with
seen.set('a', 1) - Store it with
seen.push('a', 1) - Change
Mapto a plain object type - Read the count with
seen.length
Bracket assignment adds a plain property and never touches the Map, so size stays 0.
Play Problem Solving ▸