Array to map based on object property containing array items If i have a object like following
result  = [
 {
   phones : [&quot;ABC&quot;, &quot;DEF&quot;],
   name: &quot;Simon&quot;
 },
 {
   phones : [&quot;ABC&quot;, &quot;XZY&quot;],
   name: &quot;John&quot;
 }
]

Expected output
Map of key, value
{ABC,     [&quot;Simon&quot;, &quot;John&quot;]}
{DEF,     [&quot;Simon&quot;]}
{XYZ,     [&quot;John&quot;]}

My try
map: Map = new Map();   
for ( r of result ) {
   for( phone of r.phones) {
      if(map.get(phone)){
        map.set(phone, map.get(phone).concat(r.name))
      } else {
        map.set(phone, r.name);
      }
   }
}

Is there a ES6 way to perform the above double iteration in a minimised way ?
Overall Your code is quite reasonable, after fixing something that looks to be a typo. The transformation that needs to be applied to the data structure isn't entirely trivial, so the logic that needs to be implemented requires a handful of lines of code.
Typo? But your code also has a typo/bug: the map.set(phone, r.name); will set the value in the map to be a string, not an array. You probably meant to do map.set(phone, [r.name]); (maybe a miscopy?) There's also map: Map = new Map();, which isn't valid syntax in JS, remove the : Map part.
Conditional operator If you wanted to shorten your existing code, see how you're using .map.set(phone, someExpression) depending on a condition - this is a sign that you can use the conditional operator instead of the if/else.
map.set(phone, (map.get(phone) ?? []).concat(r.name));

But while that makes the code shorter, is it easier to read? I'm not entirely convinced. Maybe you'll like it, or maybe you won't.
There are a few other things that can improve the code quality:
Declare your variables Doing for (r of result) will implicitly create a global r variable and put it on the global object. If you're running in strict mode, this will throw an error too. Always declare variables before using them, preferably with const.
Destructure? With for (r of result) or for (const r of result), you create a variable named r, which isn't so intuitive - what's an r? Maybe destructure the name and phones properties immediately.


const result  = [
 {
   phones : ["ABC", "DEF"],
   name: "Simon"
 },
 {
   phones : ["ABC", "XZY"],
   name: "John"
 }
]
const map = new Map();
for (const { phones, name } of result) {
  for (const phone of phones) {
    map.set(phone, (map.get(phone) ?? []).concat(name));
  }
}
console.log([...map]);