How to find business days in current month with Javascript?

前端 未结 2 1794
别那么骄傲
别那么骄傲 2020-12-30 18:11

How can i create function for finding numbers of business days of current month? Can you code in simple javascript without Jquery.

    function daysInMonth(i         


        
2条回答
  •  太阳男子
    2020-12-30 18:52

    Arrow function style with chaining:

    (
        (year, month) => 
            new Array(32 - new Date(year, month, 32).getDate())
            .fill(1)
            .filter(
                (id, index) =>
                    [0, 6].indexOf(
                        new Date(year, month, index + 1).getDay()) === -1
                    ).length
    )(2017, 5)
    

提交回复
热议问题