I'd like to know which would be the best way to solve this problem using javascripts native array methods(map,reduce,etc.). 

Given an array of n objects I want to create another array that will contain m objects for each element in the original array. I can do it using common "for" loops to iterate the array but I'd like to know if it can be solved with the native array methods.

Example case:

I have an array with n elements of like "ObjectA":

var objectA = {
       name: "xxx",
       tels: ["yyy","zzz"]
};


I would like to get another array of objects of type "ObjectB":

var objectB = {
       name: "xxx",
       tel: "yyy"
};


So in this case, if the first array contained only objectA, the desired result would be:

[
   {
      name: "xxx",
      tel: "yyy"
   },
   {
      name: "xxx",
      tel: "zzz"
   }
]


I've tried using two nested "map" calls, but the callback function can only return one element. 

var array1 = [objectA];

var array2 = array1.map(function(objectA){
   return objectA.tels.map(function(tel){
      return {
                 name : objectA.name,
                 tel : tel
              };
   });
});


Returning another array in the callback, generates an array of arrays and it's not what I want. Array2 result:

[
   [
      {
         name: "xxx",
         tel: "yyy"
      },
      {
         name: "xxx",
         tel: "zzz"
      }
   ]
]


Do I have to use common for loops or is there a native javascript way?


Question: Is apt-get upgrade a dangerous command?
Answer: Maybe. But you should regularly update your system. Updates can have risk, yes. This risk also depends on things I do not know such as what PPAs you may or may not have added or other sources. But again in general it's a good idea to keep you system up to date. When you update, you get stability fixes and security updates. So I will say that it is even more dangerous not to update(upgrade) your system.