Apr 15, 2025

I gave a lightning talk at NebraskaJS about the complex, decades-long relationship between JavaScript and Java’s Date APIs:

The first half was a bit of a troll; I used a Java REPL (anonymized to look like Node) to demonstrate some of the more famously unexpected behavior in the Date class:

var date = new Date("March 20 2025");
date.getMonth(); // returns 2
date.getDay(); // returns 3
date.getYear(); // returns 125??

This code is syntactically correct Java and JavaScript, and behaves identically in both languages. One of the gifts of being told to “make it like Java” when adding dates to a ten-day-old language.

Java, of course, got markedly improved…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help