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);
A Map remembers the order its keys were added and always loops in that order.
const m = new Map([["x", 1], ["y", 2]]); console.log(Object.fromEntries(m), [...m.values()]);
const apples = { name: "Apples" }; const prices = new Map([[apples, 500]]); console.log(prices.get(apples), prices.get("apples"));
If a class stores a private value with secrets.set(this, { pin }) in a WeakMap, code outside the class can read it as acct.pin.
secrets.set(this, { pin })
acct.pin
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