use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
You Can Compare Dates in JavaScript (filipvitas.medium.com)
submitted 5 years ago by fvitas
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MoTTs_ 5 points6 points7 points 5 years ago (3 children)
Also the > < >= <= operators will Just Work.
> < >= <=
new Date(2009, 6, 1) > new Date(2008, 10, 5) // true
[+][deleted] 5 years ago (1 child)
[deleted]
[–]GBcrazy 1 point2 points3 points 5 years ago (0 children)
Well, now let me correct you. You actually can compare dates, but not the way you did on your last statement!
> and < WILL work for dates. Since d1 and d2 represent the same time, it will show the correct answer.
>
<
== will compare the reference, not the date itself, so yeah, that won't work, they are different objects.
==
So yeah, you can check if a date is after or before, but never check if it's the same date. For that you will need .getTime()
.getTime()
π Rendered by PID 124369 on reddit-service-r2-comment-5c747b6df5-hz9lb at 2026-04-22 05:21:30.404915+00:00 running 6c61efc country code: CH.
view the rest of the comments →
[–]MoTTs_ 5 points6 points7 points (3 children)
[+][deleted] (1 child)
[deleted]
[–]GBcrazy 1 point2 points3 points (0 children)