title: Function is running asynchronously when it shouldn't
body: <p>I'm implementing some function in which retrieves some data of type array from firebase, 
  then search for specific element from that array and if exists, 
  I would like to abort the function and return back to the caller. 
  (React-native app)</p>
  
  <p>here is the Code: </p>
  
  <pre><code>ref.get().then(snapshot =&gt; {
      const personArr = snapshot.data().winPerson;
  
      ...
  
      if (personArr != undefined) {
        personArr.forEach(item =&gt; {
          if (item == uid.uid) {
            alert(`already subscribed`);
            return;
          }
        });
  
        if (prop.first.length != 0) {
          uploadHelper(ref, prop, "first");
        }
  
       ...
      }
  });
  </code></pre>
  
  <p>I loop through the array using forEach and see if there is matching element. If there is match, then it should alert and return to the caller function without running the subsequent code below, which is </p>
  
  <pre><code>if (prop.first.length != 0) {
          uploadHelper(ref, prop, "first");
        }
  </code></pre>
  
  <p>However, assuming that the element does exist in the array, 
  the code runs both alert and the uploadHelper function(checked through log). First I thought forEach was async function so uploadHelper executed before the return; 
  however, forEach is not async function (after some googling). </p>
  
  <p>I have no idea why uploadHelper runs if the code falls into the if (item == uid.uid) condition and returns. </p>
  
  <p>any help is appreciated. Thank you</p>