I want to get the current month's name along with the months name that are not passed in the current year. For example, current month is July and we have left August, September, October, November and December left in the current year i.e. 2021.
Following is the output I want to get:
['July', 'August', 'September', 'October', 'November', 'December']
You can do it without using any third party plugin by simply having an array and using the getMonth
function of Date
object.
// Array of all the months
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
// Current month. For `getMonth` `January` is zero.
// more here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth
const month = new Date().getMonth();
const remaining = months.slice(month);
console.log(remaining);