2022.12.27 滴滴一面

  • 自我介绍
  • 有考虑后端开发吗
  • 对前端的认识
  • 说一下知道的html标签
  • 什么时候使用p标签,session标签
  • seo
  • display: block 和flex的使用场景
  • 盒模型
  • padding margin -50%是根据哪个元素设置的
  • margin-bottom -50%表示什么意思
  • 讲一下 flex容器和子元素的css属性
  • flex主轴是哪一条
  • 实现居中
  • 用margin -宽度的一半和用translate(-50%)的区别
  • postition有哪些值,以及使用区别
  • 事件执行机制
  • 有什么宏任务和微任务
  • 事件(js事件)是什么任务,有什么区别
  • 闭包
  • 什么是内存泄漏
  • 项目中有遇到过内存泄漏的情况吗
  • 面了20多分钟,后面都是写题
  • 实现promise.finally
  • 实现节流函数
  • 实现url解析
function parse(str) {
    let index = 0
    const ans = {}
    for (let s of str) {
        if (s != '?') {

        } else {
            break
        }
        index++
    }
    // console.log(str[index]);
    index++
    while (index < str.length) {
        let s = ''
        let k = ''
        while (str[index] != '=' && index < str.length) {
            s += str[index]
            // console.log(s);
            index++
        }
        index++
        while (str[index] != '&' && index < str.length) {
            k += str[index]
            index++
        }
        // console.log(s, k);
        ans[s] = k
        index++
    }

    return ans
}

  • 实现hooks的串行调用
const hook1 = (to, from, next) => {
    console.log('hook1');
    next()
}
const hook2 = (to, from, next) => {
    setTimeout(() => {
        console.log('hook2');

        next()
    })
}
const hook3 = (to, from, next) => {
    setTimeout(() => {
        console.log('hook3');

        next(false)
    })
}
const hook4 = (to, from, next) => {
    setTimeout(() => {
        console.log('hook4');

        next()
    })
}

// const runHooks = (hooks, cb) => {
//     // 实现逻辑
// }

async function runHooks(hooks, cb) {
    let flag = true
    let done = false

    for (let hook of hooks) {
        done = false
        await new Promise((resolve) => {
            function next(arg) {
                if (arg !== undefined) {
                    flag = arg
                    // done = true

                }
                resolve()
            }

            hook('', '', next)
        })

        if (!flag) {
            cb(flag)
            return
        }

    }

    cb(undefined)
}

runHooks([hook1, hook2, hook3, hook4], (result) => {
    console.log('done', result)
})

全部评论
1 回复 分享
发布于 2023-02-01 13:15 广东
这个点还能捞,厉害了
1 回复 分享
发布于 2023-01-06 09:46 湖北
咋手写这么多
1 回复 分享
发布于 2023-01-02 17:03 上海
楼主 滴滴面试都没问项目么
点赞 回复 分享
发布于 2023-02-10 11:45 北京
我今天面的 好多问题一样 我之前没看见你这个
点赞 回复 分享
发布于 2023-01-12 21:07 福建
楼主面的哪个部门呀
点赞 回复 分享
发布于 2023-01-10 12:04 北京

相关推荐

大猪蹄子哥:1-谁教你这么写教育经历的……咱都这个学历了,很多公司要看本科、硕士,Gap Year的,你啪就给一个上大26届硕士,没了。 2-那堆奖学金揉成一行放最后得了,放前面显得你没技术自信,还是那句话,对于咱这个学历直接上重点,你这上半段看起来像个大专(无恶意 3-专业技能最好点出来细化方向,你熟悉的以太网是UDP还是TCP,是千兆还是万兆等等,多种信号处理……那你倒是说两个啊,后面空着干嘛,会的干嘛不讲 4-项目经历废话太多,描述不专业(怎么还有我,我们这种词),没有数据支撑(是婴儿还是巨人看不出来)。最后如果这些是真的XX项目、比赛,最好点出来,不然更显得像自学着玩的,或者说抄的(经典复现等于我做过 5-个人总结在咱这个分段没用
点赞 评论 收藏
分享
评论
11
18
分享

创作者周榜

更多
牛客网
牛客企业服务