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:
const months= ["1", "4", "7", "9"];
const years = ["2021", "2022", "2027"];
The necessary result is the first day of each month + year combination, like so:
const dates = [
"1/1/2021", "4/1/2021", "7/1/2021", "9/1/2021",
"1/1/2022", "4/1/2022", "7/1/2022", "9/1/2022",
"1/1/2027", "4/1/2027", "7/1/2027", "9/1/2027"
];
The way I would do this in T-SQL is as follows -
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;
So, is there a cross join equivalent in Javascript? I'd rather use a concise approach like that rather than nested .forEach() statements.
