According to MDN:
Map.length
The value of the length property is 0.
What is the use case for this? I understand why Map.size is semantically correct. But surely a Map.length that almost always returns the "wrong" answer is a bad idea, especially if there's an oversight migrating code from ES5. Is there a way to force an error when this is used?
Constructors in JavaScript are regular functions, and the length property of a function corresponds to the number of formal parameters expected by the function, which is 0 in the case of Map.
Contrast this with RegExp.length, which is 2, because the RegExp constructor expects two parameters (pattern and flags).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With