-1

I am setting a javascript dateobject to null. However, when I do a console log on the date, it shows 12/31/1969. What is the correct way to check if a date is null in javascript if it is being converted to this type of date value?

mo_maat
  • 2,110
  • 12
  • 44
  • 72
  • 1
    `if(yourDate === null)` ? – Seblor Mar 19 '21 at 23:11
  • Does this answer your question? [Detecting an "invalid date" Date instance in JavaScript](https://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript) – Lil Devil Mar 19 '21 at 23:18

1 Answers1

0

I am not sure what you understand by "I am setting a javascript date object to null" but you can try this example and check if it works.

let date = new Date();
date = null;

console.log(date); // null
Kishieel
  • 1,811
  • 2
  • 10
  • 19