title: Javascript Promise push value into array (only from function or outside?)
body: <p>I have some promises and a Promise.all:</p>
  
  <pre><code>array = [];
  
  
    var one = new Promise(function(resolve, reject) {
      // Do stuff
      setTimeout(function() {
        resolve('One Done');
        array.push('one');
      }, 5000);
    });
  
  
    var two = new Promise(function(resolve, reject) {
      // Do Stuff
      resolve('Two Done');
      array.push('two');
    });
  
  
    Promise.all(array).then(values =&gt; {
      console.log(values);
    });
  </code></pre>
  
  <p>We know this doesn't work because array.push needs to be outside.</p>
  
  <p>I currently have a few functions which I need to have called by promises so that finally I can have it in Promise.all.</p>
  
  <p>Would it be advisable to call the function from inside the promise like this:</p>
  
  <pre><code>    function dosomething() {
          // does something
          array.push('something');
      }
  
    var mypromise = new Promise(function(resolve, reject) {
      dosomething();
      resolve('Did something');
    });
  </code></pre>
  
  <p>Or is there a more advisable way to do this?</p>