DEV Community

loading...
Cover image for JavaScript Interview Question #26: Are these dates equal?

JavaScript Interview Question #26: Are these dates equal?

Coderslang: Become a Software Engineer
Teaching you to code at js.coderslang.com - JavaScript, HTML, CSS, Node.js, React.js, React Native
Originally published at learn.coderslang.com on ・1 min read

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

Discussion (0)