How to check if a date falls between two other dates in javascript

Image source: Unsplash
Introduction to moment.js:
Momentjs is a lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
Use cases of momentjs:
Momentjs is the most widely used library to handle date-related operations in JavaScript. The reason being, it reduces and simplifies any required date operation which might take many lines using Date() function to a single line of code 
Checking whether a date is between two dates using moment in node.js
const moment = require('moment');
const dateFormat = "DD-MM-YYYY";
const newYear = moment("01-01-2019", dateFormat);
const christmas = moment("25-12-2018", dateFormat);
const yearEnd = moment("31-12-2018", dateFormat);
if(yearEnd.isBetween(christmas, newYear)){
  console.log("Year end falls between christmas🎄 and new year🎇");

Year end falls between christmas🎄 and new year🎇
Example Explanation: In the above example, we have first initialized newYear, Christmas and yearEnd variables by passing date and the format in which the date is specified to moment function. The dateFormat variable to allow the moment to understand in which format we want to add the date input.Next, we use the isBetween function to check if yearEnd is between Christmas and newYear. If we get the value as true then output appropriate statement to console.
Hope you do check out other moment.js functions for various use cases in your upcoming projects🙂