javascript 获取指定年份到当年的年份数组方法:

function getYears(){
    var current = new Date().getFullYear();
    var diff = current - 2022;
    var years = [];
    for (var i = 0; i < diff; i++) {
        years.push(current--);
    }
    return years;
}