This is driving me crazy!
console.log(new Date(2020, 11, 4));
A simple date, 4th of November 2020.
Output:
Fri Dec 04 2020 00:00:00 GMT+0000 (Greenwich Mean Time)
WHAT!
So lets try an alternative:
const now = new Date()
console.log(now.getFullYear(), now.getMonth(), now.getDate());
Outputs:
Thu Oct 29 2020 10:12:56 GMT+0000 (Greenwich Mean Time)
Lets confirm some things now:
typeof now.getFullYear();
"number"
typeof now.getMonth();
"number"
typeof now.getDate();
"number"
typeof 2020
"number"
typeof 11
"number"
typeof 4
"number"
What is going on?