title: match Vs exec in JavaScript
body: <p>I need some clarification for match Vs exec in JavaScript; <a href="https://stackoverflow.com/questions/9214754/what-is-the-difference-between-regexp-s-exec-function-and-string-s-match-fun">here</a> some one says that </p>
  
  <p><em>"exec with a global regular expression is meant to be used in a loop"</em> but first of all as you see in my example this is not the case; in my example exec with global regular expression is returning all of the matches in an array! Secondly they say that for String.match it returns all of the matches with  no need of looping through! But again that's not happening in my example and it is just returning the input string? Have I misunderstood/done something wrong?</p>
  
  <pre><code>var myString = "[22].[44].[33].";
  var myRegexp = /.*\[(\d*)*\].*\[(\d*)*\].*\[(\d*)*\].*/g;
  
  var execResult = myRegexp.exec(myString);
  console.log(execResult.length);
  console.log(execResult[1]);// returns 22 and execResult has all of my matches from index 1 to the length of array
  
  
  var matchResult = myString.match(myRegexp);
  console.log(matchResult.length);
  console.log(matchResult);// returns just myString which is "[22].[44].[33]."! Why is that?
  </code></pre>