title: cross join equivalent in JavaScript
body: <p>In an app that's being developed there is a use case whereby dates need to be generated from an array of months and another array of years.  Here is an example of representative data in those arrays:</p>
  <pre><code>const months= [&quot;1&quot;, &quot;4&quot;, &quot;7&quot;, &quot;9&quot;];
  const years = [&quot;2021&quot;, &quot;2022&quot;, &quot;2027&quot;];
  </code></pre>
  <p>The necessary result is the first day of each month + year combination, like so:</p>
  <pre><code>const dates = [
  &quot;1/1/2021&quot;, &quot;4/1/2021&quot;, &quot;7/1/2021&quot;, &quot;9/1/2021&quot;,
  &quot;1/1/2022&quot;, &quot;4/1/2022&quot;, &quot;7/1/2022&quot;, &quot;9/1/2022&quot;,
  &quot;1/1/2027&quot;, &quot;4/1/2027&quot;, &quot;7/1/2027&quot;, &quot;9/1/2027&quot;
  ];
  </code></pre>
  <p>The way I would do this in T-SQL is as follows -</p>
  <pre><code>select *
  into #months
  from
  (
      values
      (1),
      (4),
      (7),
      (9)
  ) d (month);
  
  select *
  into #years
  from
  (
      values
      (2021),
      (2022),
      (2027)
  ) d (year);
  
  select [dates] = datefromparts(year, month, 1)
  from #months
  cross join #years;
  </code></pre>
  <p>Output:<br>
  <a href="https://i.stack.imgur.com/EuXUG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EuXUG.png" alt="enter image description here" /></a></p>
  <p>So, is there a cross join equivalent in Javascript?  I'd rather use a concise approach like that rather than nested <code>.forEach()</code> statements.</p>