getYears
This function returns an array of years within a specified range, inclusive of the start and end dates.
Parameters
startDate
(optional, default: 1850): The starting year.endDate
(optional, default: Current year): The ending year.
Returns
An array of numbers representing the years between the specified start and end dates.
Throws
An error is thrown if the end date is less than the start date.
Without any param will start from 1850 till the current year
getYears()// [1850,1851,1852,1853,1854,1855,1856,...2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024]
With param
this will return the years from the given till the current year
getYears(2016) // [2016,2017,2018,2019,2020,2021,2022,2023,2024]
getYears(2019,2023); //[2019,2020,2021,2022,2023]
Last updated