Skip to main content
InterviewHubPRO
Section Overview
Q137

Question 137 of 536

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

26%
JavaScript & V8 Internals (536 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

How do you compare two date objects

mid LevelCode ExampleHTTP & REST APIs

You need to use date.getTime() method in order to compare unix timestamp values

javascript
  var d1 = new Date();
  var d2 = new Date(d1);
  console.log(d1.getTime() === d2.getTime()); //True
  console.log(d1 === d2); // False