Map keeps insertion order and takes objects as keys

A plain object as a lookup coerces every key to a string, so 1 and "1" collide, and an object key becomes the useless string [object Object]. Map keeps keys as they are.

const seen = new Map();
seen.set(nodeA, { visits: 1 });
seen.get(nodeA);        // works — identity, not string

const counts = new Map();
counts.set(1, 'int').set('1', 'string');
counts.size;            // 2

It also iterates in insertion order, which objects only approximately do, and it has a real size rather than Object.keys(o).length. The reason not to reach for it every time is JSON: a Map does not serialise, so anything crossing a network boundary or going into localStorage has to be converted back to an object first.