I have Map in my angular component as key being object of class Group and value being an array of class Match which basically says group and matches that will take place among the group members of that group. .
Map< Group, Match[]>
I want to have the total number of entries in the map and length of match array as well. How do I do that?
I've tried map.size and map.values().next().length
Sometimes newMap.size
gives undefined
value. Use this simple code to find map size.
Object.keys(newMap).length
I encountered a similar problem. You have to call the Map constructor. My original code was:
let a : Map<string,number> = {} as Map<string,number>;
Map.size //undefined
If you call it properly, then works:
let a: Map<string,number> = new Map<string,number>();
Map.size //the right size
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