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

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)