Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaScriptMap Set WeakMapSingle-choice MCQ

Why does the second set() call throw here, and which key types are valid for a WeakMap?

const wm = new WeakMap(); wm.set({}, 1); // line A wm.set('id', 2); // line B