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-03-15 11:20
春招专场
校招火热招聘中
官网直投
第二题代码看得懂,就是不懂面试官问的啥,能讲讲count是什么意思吗
点赞 回复
分享
发布于 2021-03-21 00:27
为啥不是三面鸭
点赞 回复
分享
发布于 2021-04-16 17:33

相关推荐

3 19 评论
分享
牛客网
牛客企业服务