Guest practice: this set is not saved and does not count.
What does this log?
const m = new Map(); m.set(1, "number"); m.set("1", "string"); const o = {}; o[1] = "number"; o["1"] = "string"; console.log(m.size, Object.keys(o).length);
const plain = {}; const map = new Map(); console.log("constructor" in plain, map.has("constructor"));
const apples = { name: "Apples" }; const prices = new Map([[apples, 500]]); console.log(prices.get(apples), prices.get("apples"));
const wm = new WeakMap(); const k = {}; wm.set(k, 1); console.log(wm.get(k), wm.has({}), wm.size);
const visits = new WeakMap(); const paul = { name: "Paul" }; function track(person) { visits.set(person, (visits.get(person) ?? 0) + 1); } track(paul); track(paul); track(paul); console.log(visits.get(paul));
Click a question to go back and check it. After you submit, you will see the right answer and an explanation for every question. As a guest, nothing is saved.
Check my answers