1
            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日.直接可以快速判断该年是不是闰年了,哈哈

唧唧陆
8 声望0 粉丝

帅帅的丑八怪


« 上一篇
闭包函数