判断是不是闰年

function isLeapYear(year){
                let date = new Date(year + "-02-29");
                if(date.getDate() == 29){
                    console.log(year + "是闰年");
                }else{
                    console.log(year + "不是闰年")
                }
            }
            
            
            我发现若是该年不是闰年,new Date("2019-02-29").getDate()返回的不是29,也不回报错,而是返回1,他会帮你转变成3月1日.直接能够快速判断该年是否是闰年了,哈哈
相关文章
相关标签/搜索