I am working on implementing a dynamic select box in JavaScript that should display a range of years, starting from a specific year and ending with the current one. I'm curious if there is anything similar to Ruby's range class in JavaScript or if I'll have to iterate through the years using a for loop.
Here's my initial solution, but I feel like it may be overly complex compared to what could be achieved more easily in Ruby using a range.
this.years = function(startYear){
startYear = (typeof(startYear) == 'undefined') ? 1980 : startYear
var currentYear = new Date().getFullYear();
var years = []
for(var i=startYear;i<=currentYear;i++){
years.push(i);
}
return years;
}