The answer is simple and beautiful:
function returningMap() { const someMap = new Map(); someMap.set("key", {a, b, c}); return someMap; }
Main template Map<KeyType, ValueType> . In your example, the key will be the string and value of the object. You can even go and declare your object. For instance:
And then your map will be declared as Map<String, MyObject> . Cool, right? You can also nest other maps or even sets, for example Map<Number, Set<MyObject>> .
source share