// Practice Set · JS Maps · guest

Guest practice: this set is not saved and does not count.

Question 1 of 5 from: JS Maps

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);
Question 2 of 5 from: JS Maps

A Map remembers the order its keys were added and always loops in that order.

Question 3 of 5 from: JS Map Methods

What does this log?

const m = new Map([["x", 1], ["y", 2]]);
console.log(Object.fromEntries(m), [...m.values()]);
Question 4 of 5 from: JS Map Methods

What does this log?

const apples = { name: "Apples" };
const prices = new Map([[apples, 500]]);
console.log(prices.get(apples), prices.get("apples"));
Question 5 of 5 from: JS Map WeakMap

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.

Ready to submit?

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.