JavaScript Weirdness
Published ....
Last modified ....
Share this post on BlueskySee discussion on Bluesky
Okay, in case you didn't know already, Javascript is a funky language.
I am currently working on a simple calendar web app using CSS Grid and a bit of react, so I wanted to generate an array of arrays storing the days in each month in each year. I was hoping to do this with some fancy forEach loops so I started with the following code:
const year = new Array(12).fill([]);
I was hoping this would return something like this:
year = [[], [], [], [], [], [], [],