CVTE前端二面面经

1、项目难点
2、100个http会有多少条TCP连接。
3、http2.0头压缩算法了解不
4、异步编程题
题目一
function queue(list){
        // 在这里填写。
}
  
function task1(next){
  setTimeout(function(){
    console.log(1);
    next();
  }, 10000)
}

function task2(next){

  console.log(2)
  next();
}

function task3(next){

  setTimeout(function(){
    console.log(3);
    next();
  }, 200)
}

queue([task1, task2, task3])  // 1 2 3
我自己的参考答案
// 参考答案
function queue(list){
  let fn = list.shift();
  fn(next);
  function next(){
    if(list.length === 0) return;
    let fn = list.shift();
    fn(next);
  }
}
题目二
function queue(list, count){

}
  
function task1(next){
  setTimeout(function(){
    console.log(1);
    next();
  }, 1000)
}

function task2(next){

  console.log(2)
  next();
}

function task3(next){

  setTimeout(function(){
    console.log(3);
    next();
  }, 200)
}
queue([task1, task2, task3], 2)  // 输出 2 3 1
我自己的参考答案
function queue(list, count){
  let array = list.splice(0,count);
  for(let fn of array) {
    fn(next);
  }
  function next(){
    let array = list.splice(0,count);
    for(let fn of array) {
      fn(next);
    }
  }
}
后续 ,最后沟通OC了。



#面经##广州视源电子科技股份有限公司##前端工程师##校招#
全部评论
楼主你好,请问你是实习、校招还是社招?
2 回复 分享
发布于 2021-01-15 12:55
为啥不是三面鸭
点赞 回复 分享
发布于 2021-04-16 17:33
第二题代码看得懂,就是不懂面试官问的啥,能讲讲count是什么意思吗
点赞 回复 分享
发布于 2021-03-21 00:27
第二题是多少条为什么啊
点赞 回复 分享
发布于 2021-03-15 11:20

相关推荐

uu们,拒offer时hr很生气怎么办我哭死
爱睡觉的冰箱哥:人家回收你的offer,或者oc后没给你发offer的时候可不会愧疚你,所以你拒了也没必要愧疚他。
点赞 评论 收藏
分享
06-11 17:39
门头沟学院 Java
小呆呆的大鼻涕:卧槽,用户彻底怒了
点赞 评论 收藏
分享
Twilight_m...:经典我朋友XXXX起手,这是那种经典的不知道目前行情搁那儿胡编乱造瞎指导的中年人,不用理这种**
点赞 评论 收藏
分享
评论
3
19
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务