How to get first and last date of the current month with JavaScript?

JavascriptWeb DevelopmentFront End Technology

To get the first and last date of current month in JavaScript, you can try to run the following code −

      <title>JavaScript Dates</title>
         var date = new Date();
         document.write("Current Date: " + date );
         var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
         var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
Published on 14-Feb-2018 08:17:16