4 ms·
Yes the square brackets were just a typo. But maps do support float keys - you can try it yourself! map = new Map(); map.set(1.2, 3.4); log(typeof(map.ke
by chrisseaton 4y ago
Yes the square brackets were just a typo. But maps do support float keys - you can try it yourself!
map = new Map();
map.set(1.2, 3.4);
log(typeof(map.keys().next().value));
That says the key is a number, and it's a floating point number. So what did they mean by "ECMAScript does not have maps where keys can be integers and neither can keys be floats"?
- xg15 4y agoAh, I misunderstood that, sorry. I think the GP was wrong there. JS maps absolutely do support float keys, it's just generally a bad idea to use them if you don't restrict yourself to integers.