title: why javascript not wait for and of forEach and execute next line
body: <p>when I create my api in nodejs and trying to pushing mongoose return count to new created array, it's not wait for the forEach and execute json.res() and giving null response. when I use 
  <strong>setTimeout()</strong> then it's giving proper result.</p>
  
  <pre class="lang-js prettyprint-override"><code>let newcategories = [];
  let service = 0;
  const categories = await Category.find({}, '_id name');
  categories.forEach(async (category) =&gt; {
  
  service = await Service.count({category: category});
  
  newcategories.push({ count:service });
  console.log('newcategories is -- ', newcategories);
  
  });  /* while executing this forEach it's not wait and execute res.json..*/
  
  
  console.log('result --- ',result);
  console.log('out newcategories is -- ', newcategories);
  res.json({status: 200, data: newcategories});
  </code></pre>