秋招笔试之微众银行

发布于:2022-12-17 ⋅ 阅读:(482) ⋅ 点赞:(0)

1.选A

 首先Location 对象是 Window 对象的一个部分,可通过 window.location 属性来访问

关于location对象的各个属性实例

javascript-一篇搞懂location对象!!(建议收藏)_半糖冰的博客-CSDN博客_js銝衍ocation撖寡情 

关于location.pathname和location.href的区别location.href/location.search/location.pathname区别及用法_谁动了我的bug的博客-CSDN博客​​​​​​l

另外注意区分host和hostname(hostname只是域名,host是域名+端口号)

2.选C

关于canvas标签canvas基本用法_生菜骨灰级爱好者的博客-CSDN博客_canvas使用 

3.选A 

关于super方法

Javascript 中的 super - 知乎 

①super首先可以作为父类的构造函数,在子类的constructor中this之前调用

②super也可以作为对象,调用父类的方法。并且在普通函数里时,super指的是父类的原型对象,在静态方法中时,super指的是父类

4.

 column-gap只是各个列之间的间距是40px

分割线属性设置:

 

5.

 

6.

 var arrToTree = (arr) => {
            var treeData = []
            arr.forEach(item => {
                treeData.push(item)
                // 找当前节点的子节点
                let kidsOfCurNodeArr = arr.filter(data => {
                    return data.parentId === item.id
                })
                item.children = kidsOfCurNodeArr

            })
            return treeData
        }

        // 目标:
        let arr = [
            { id: 0, value: 'A', parentId: -1 },
            { id: 1, value: 'B', parentId: 0 },
            { id: 2, value: 'C', parentId: 0 },
            { id: 3, value: 'D', parentId: 1 },
            { id: 4, value: 'E', parentId: 1 },
            { id: 5, value: 'F', parentId: 2 }
        ]
        const treeData = arrToTree(arr)
        console.log(treeData);

7.数组去重函数

// 数组去重函数

// 法一:利用set的元素唯一性的特性
var deleteSame1 = (arr) => {
    let tmp = new Set(arr)
    return Array.from(tmp)
}

// 法二:利用一个空数组装不重复的元素
var deleteSame2 = (arr) => {
    let res = []
    arr.forEach(ele => {
        if (res.indexOf(ele) === -1) {
            res.push(ele)
        }
    })
    return res
}

// 

let arr = [1, 1, 1, 2, 3, 4, 4, 4, 5, 6, 7]
console.log(deleteSame2(arr));

 

 

8.

// 求两个日期中间的有效日期
// 示例:
// 输入: 2020-9-29~2020-10-3
// 输出:['2020-9-29','2020-9-30','2020-10-1','2020-10-2','2020-10-3']

var validDate = (str) => {

    var monthArr = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

    var tmp = str.split('~')
    // console.log(tmp);
    var startYear = parseInt(tmp[0].split('-')[0])
    var startMonth = parseInt(tmp[0].split('-')[1])

    var endYear = parseInt(tmp[1].split('-')[0])
    var endMonth = parseInt(tmp[1].split('-')[1])

    var beginDay = parseInt(tmp[0].split('-')[2])
    var endDay = parseInt(tmp[1].split('-')[2])

    var res = []
    // res.push(tmp[0])
    // res.push(tmp[1])

    for (let y = startYear; y <= endYear; y++) {
        let startm = 1
        let endm = 12
        if (y === startYear) {
            startm = startMonth

        }
        if (y === endYear) {
            endm = endMonth
        }

        var initStr = []

        for (let m = startm; m <= endm; m++) {
            // 得到当前月份的天数
            let days = monthArr[m]

            var initStr = [y, m]

            if (isRunYear(y) && m === 2) {
                days += 1
            }

            let begindD = 1
            let endD = days

            if (m === startMonth) {
                begindD = beginDay

            }
            if (m === endMonth) {
                endD = endDay
            }
            for (let d = begindD; d <= endD; d++) {
                initStr[2] = d
                let r = initStr.join('-')
                res.push(r)
            }

        }
    }
    console.log(res);
}

var isRunYear = (curYear) => {
    if (curYear % 4 === 0 && curYear % 100 !== 0) {
        return 1
    }
    else if (curYear % 400 == 0) {
        return 1
    }
    return 0
}


validDate('2020-9-29~2020-10-3')

本文含有隐藏内容,请 开通VIP 后查看