Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
const a = new Date("2024-06-01"); const b = new Date("2024-12-31"); a < b // true a > b // false // Equality requires .getTime() a === b // false (different objects) a.getTime() === b.getTime() // true if same moment // Check if a date is in the past function isPast(date) { return date.getTime() < Date.now(); } // Sort array of dates dates.sort((a, b) => a - b); // ascending
Result
Open