DEV Community

Cover image for JavaScript Interview Question #26: Are these dates equal?
Coderslang: Become a Software Engineer
Coderslang: Become a Software Engineer

Posted on • Originally published at learn.coderslang.com on

6 3

JavaScript Interview Question #26: Are these dates equal?

js-test-26

Equal or not?

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

In the first two lines, we create new Date objects.

In line 4, we’re using the strict equality operator ===. Remember that we’re comparing different objects!

Even if date and date2 represented the same date, the check would have returned false.


ANSWER: The string not so much will be printed to the console, as date1 and date2 are different objects.

Learn Full Stack JavaScript

Top comments (0)

This post blew up on DEV in 2020:

js visualized

🚀⚙️ JavaScript Visualized: the JavaScript Engine

As JavaScript devs, we usually don't have to deal with compilers ourselves. However, it's definitely good to know the basics of the JavaScript engine and see how it handles our human-friendly JS code, and turns it into something machines understand! 🥳

Happy coding!

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay