memesearch
JavaScript Month Days Trick

JavaScript Month Days Trick

Download Find similar pictures
Text on the meme
getting the number of days in a month in js is kinda funny new Date( year, month, 0 ).getDate() two hidden off-by-ones are working in our favor: • month 1 is actually february • day 1 is the first day, so day 0 is the last day of the previous month :3c
What it means

A dark-mode social media post explains a JavaScript trick for finding the number of days in a month using `new Date(year, month, 0).getDate()`. The joke is that two confusing off-by-one behaviors—zero-based months and day zero referring to the previous month’s last day—happen to make the code work. It is shared as a humorous reaction by programmers who recognize JavaScript’s quirky date handling. EN: A dark-mode social media post explains a JavaScript trick for finding the number of days in a month using `new Date(year, month, 0).getDate()`. The joke is that two confusing off-by-one behaviors—zero-based months and day zero referring to the previous month’s last day—happen to make the code work. It is shared as a humorous reaction by programmers who recognize JavaScript’s quirky date handling.

Objects
Tags
Source
Template
Programming tweet screenshot
Type
image
Size
800×649 · 63.0 KiB
Mood
nerdy, amused
Language
en
Added