3 ms·
What do you think is happening when you use set with a float on a map? How do you explain this? const map = new Map(); map.set(1, 3); map.get(1);
by chrisseaton 4y ago
What do you think is happening when you use set with a float on a map?
How do you explain this?
const map = new Map();
map.set(1, 3);
map.get(1); // 3
map.set(1.2, 3.4);
map.get(1.2); // 3.4
typeof map.keys().next().value; // "number"
Where do you think ‘number’ comes from?
Read the spec - it supports primitives for keys and it doesn’t stringing them. As others have said in this thread - you’re just wrong.
- deleted 4y ago[deleted]